diff --git a/cli/.gitignore b/cli/.gitignore
deleted file mode 100644
index 3ddbf4c..0000000
--- a/cli/.gitignore
+++ /dev/null
@@ -1,32 +0,0 @@
-### IntelliJ IDEA ###
-out/
-!**/src/main/**/out/
-!**/src/test/**/out/
-
-### Kotlin ###
-.kotlin
-
-### Eclipse ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-bin/
-!**/src/main/**/bin/
-!**/src/test/**/bin/
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-
-### VS Code ###
-.vscode/
-
-### Mac OS ###
-.DS_Store
\ No newline at end of file
diff --git a/cli/.idea/.gitignore b/cli/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/cli/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/cli/.idea/codeStyles/Project.xml b/cli/.idea/codeStyles/Project.xml
deleted file mode 100644
index 1bec35e..0000000
--- a/cli/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/.idea/codeStyles/codeStyleConfig.xml b/cli/.idea/codeStyles/codeStyleConfig.xml
deleted file mode 100644
index 79ee123..0000000
--- a/cli/.idea/codeStyles/codeStyleConfig.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/.idea/inspectionProfiles/Project_Default.xml b/cli/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index df543e3..0000000
--- a/cli/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/.idea/kotlinc.xml b/cli/.idea/kotlinc.xml
deleted file mode 100644
index 3777884..0000000
--- a/cli/.idea/kotlinc.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/.idea/libraries/KotlinJavaRuntime.xml b/cli/.idea/libraries/KotlinJavaRuntime.xml
deleted file mode 100644
index d777bf6..0000000
--- a/cli/.idea/libraries/KotlinJavaRuntime.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/.idea/misc.xml b/cli/.idea/misc.xml
deleted file mode 100644
index 6f29fee..0000000
--- a/cli/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/.idea/modules.xml b/cli/.idea/modules.xml
deleted file mode 100644
index 7f2948e..0000000
--- a/cli/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/.idea/vcs.xml b/cli/.idea/vcs.xml
deleted file mode 100644
index 6c0b863..0000000
--- a/cli/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/cli.iml b/cli/cli.iml
deleted file mode 100644
index 8dfb729..0000000
--- a/cli/cli.iml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cli/dao.cpp b/cli/dao.cpp
new file mode 100644
index 0000000..ece3f82
--- /dev/null
+++ b/cli/dao.cpp
@@ -0,0 +1,27 @@
+#include
+#include
+
+#include "include/dao.h"
+
+using namespace std;
+
+void Dao::populate_env() {
+ this->api_key = getenv("FRONTEND_API_KEY");
+ this->db_url = getenv("DB_URL");
+}
+
+ticket_t Dao::fetch_ticket_create(string title, string description) {
+
+}
+
+vector Dao::fetch_ticket_get_all() {
+
+}
+
+vector Dao::fetch_ticket_get_by_status(string status) {
+
+}
+
+ticket_t Dao::fetch_ticket_get_by_id(unsigned long id) {
+
+}
\ No newline at end of file
diff --git a/cli/handler.cpp b/cli/handler.cpp
new file mode 100644
index 0000000..b7268cd
--- /dev/null
+++ b/cli/handler.cpp
@@ -0,0 +1,38 @@
+#include
+#include
+
+#include "include/handler.h"
+#include "include/printer.h"
+#include "include/dao.h"
+
+using namespace std;
+
+/** TODO: error propagation?? (now always returns 0) */
+
+int handle_create(Dao *dao, string title, string description) {
+ ticket_t t = dao->fetch_ticket_create(title, description);
+ vector tickets;
+ tickets.push_back(t);
+ print_tickets(tickets);
+ return 0;
+}
+
+int handle_list(Dao *dao) {
+ vector tickets = dao->fetch_ticket_get_all();
+ print_tickets(tickets);
+ return 0;
+}
+
+int handle_list(Dao *dao, string status) {
+ vector tickets = dao->fetch_ticket_get_by_status(status);
+ print_tickets(tickets);
+ return 0;
+}
+
+int handle_detail(Dao *dao, unsigned long id) {
+ ticket_t t = dao->fetch_ticket_get_by_id(id);
+ vector tickets;
+ tickets.push_back(t);
+ print_tickets(tickets);
+ return 0;
+}
diff --git a/cli/include/dao.h b/cli/include/dao.h
new file mode 100644
index 0000000..0cc8373
--- /dev/null
+++ b/cli/include/dao.h
@@ -0,0 +1,23 @@
+#ifndef DAO_H
+#define DAO_H
+
+#include
+#include
+
+#include "ticket.h"
+
+using namespace std;
+
+class Dao {
+public:
+ string api_key;
+ string db_url;
+ void populate_env();
+
+ ticket_t fetch_ticket_create(string title, string description);
+ vector fetch_ticket_get_all();
+ vector fetch_ticket_get_by_status(string status);
+ ticket_t fetch_ticket_get_by_id(unsigned long id);
+};
+
+#endif // DAO_H
\ No newline at end of file
diff --git a/cli/include/handler.h b/cli/include/handler.h
new file mode 100644
index 0000000..3845761
--- /dev/null
+++ b/cli/include/handler.h
@@ -0,0 +1,15 @@
+#ifndef HANDLER_H
+#define HANDLER_H
+
+#include
+
+#include "dao.h"
+
+using namespace std;
+
+int handle_create(Dao *dao, string title, string description);
+int handle_list(Dao *dao);
+int handle_list(Dao *dao, string status);
+int handle_detail(Dao *dao, unsigned long id);
+
+#endif // HANDLER_H
diff --git a/cli/include/parser.h b/cli/include/parser.h
new file mode 100644
index 0000000..876ad3a
--- /dev/null
+++ b/cli/include/parser.h
@@ -0,0 +1,8 @@
+#ifndef PARSER_H
+#define PARSER_H
+
+#include "dao.h"
+
+int parse_args(Dao *dao, int argc, char *argv[]);
+
+#endif // PARSER_H
diff --git a/cli/include/printer.h b/cli/include/printer.h
new file mode 100644
index 0000000..bff8913
--- /dev/null
+++ b/cli/include/printer.h
@@ -0,0 +1,12 @@
+#ifndef PRINTER_H
+#define PRINTER_H
+
+#include
+
+#include "ticket.h"
+
+using namespace std;
+
+void print_tickets(vector tickets);
+
+#endif // PRINTER_H
\ No newline at end of file
diff --git a/cli/include/ticket.h b/cli/include/ticket.h
new file mode 100644
index 0000000..1111dd7
--- /dev/null
+++ b/cli/include/ticket.h
@@ -0,0 +1,18 @@
+#ifndef TICKET_H
+#define TICKET_H
+
+#include
+#include
+
+using namespace std;
+
+typedef struct {
+ unsigned long id;
+ string title;
+ string description;
+ string status;
+ string created_at;
+ string updated_at;
+} ticket_t;
+
+#endif // TICKET_H
\ No newline at end of file
diff --git a/cli/main.cpp b/cli/main.cpp
new file mode 100644
index 0000000..2f5ab00
--- /dev/null
+++ b/cli/main.cpp
@@ -0,0 +1,9 @@
+#include "include/parser.h"
+#include "include/dao.h"
+
+int main(int argc, char *argv[], char *envp[]) {
+ Dao *dao = new Dao();
+ dao->populate_env();
+ int retval = parse_args(dao, argc, argv);
+ delete dao;
+}
diff --git a/cli/parser.cpp b/cli/parser.cpp
new file mode 100644
index 0000000..b47d66a
--- /dev/null
+++ b/cli/parser.cpp
@@ -0,0 +1,62 @@
+#include
+#include
+#include
+#include
+
+#include "include/parser.h"
+#include "include/handler.h"
+
+using namespace std;
+
+void show_usage() {
+ cout << "usage:\n"
+ "these env vars have to be set: FRONTEND_API_KEY, DB_URL"
+ "tickets create \n"
+ "tickets list [-status ]\n"
+ "tickets detail " << endl;
+}
+
+#define show_usage_and_die() show_usage(); return 1;
+
+int parse_args(Dao *dao, int argc, char *argv[]) {
+ if (argc == 1) { // not enough args
+ show_usage_and_die();
+ }
+
+ if (strcmp(argv[1], "create") == 0) { // creating a ticket
+ if (argc != 4) {
+ show_usage_and_die();
+ }
+
+ return handle_create(dao, argv[2], argv[3]); // title and description
+ }
+
+
+ if (strcmp(argv[1], "list") == 0) { // listing tickets (optional filter by status)
+ if (argc != 2 || argc != 4) {
+ show_usage_and_die();
+ }
+
+ if (argc == 4) {
+ if (strcmp(argv[2], "-status") == 0) {
+ return handle_list(dao, argv[3]); // the status text
+ }
+ }
+
+ // now we know that argc == 2
+ // -> handle list (get all tickets)
+ return handle_list(dao);
+ }
+
+ if (strcmp(argv[1], "detail") == 0) {
+ if (argc != 3) {
+ show_usage_and_die();
+ }
+
+ int ticket_id = atoi(argv[2]);
+
+ return handle_detail(dao, ticket_id); // ticket id
+ }
+
+ return 0;
+}
diff --git a/cli/printer.cpp b/cli/printer.cpp
new file mode 100644
index 0000000..bbfa058
--- /dev/null
+++ b/cli/printer.cpp
@@ -0,0 +1,16 @@
+#include
+
+#include "include/printer.h"
+
+void print_tickets(vector tickets) {
+ for (ticket_t t : tickets) {
+ cout << "/------+-------\n"
+ "|Ticket| id: " << t.id << "\n"
+ "+------/ title: " << t.title << "\n"
+ "| description: " << t.description << "\n"
+ "| status: " << t.status << "\n"
+ "| created at: " << t.created_at << "\n"
+ "| updated at: " << t.updated_at << "\n"
+ "\\--------------" << endl;
+ }
+}
\ No newline at end of file
diff --git a/cli/src/Main.kt b/cli/src/Main.kt
deleted file mode 100644
index bf2b0ee..0000000
--- a/cli/src/Main.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * TICKETS
- *
- * a Linux cli for the mini ticket system written in C
- * features:
- * - create a ticket
- * `tickets create `
- * - list all tickets (or filter by status)
- * `tickets list --status=(open|in_progress|closed)`
- * - detail of one ticket
- * `tickets detail `
- */
-
-fun showUsage() {
- println("usage:\n" +
- " tickets create \n" +
- " tickets list --status (open|in_progress|closed)\n" +
- " tickets detail \n")
-}
-
-fun parseCreate(title: String, description: String) {
- println("CREATE: creating a ticket with\n" +
- "title='$title'\n" +
- "description='$description'")
-}
-
-fun parseList(status: String) {
- println("LIST: listing items with status '$status'")
-}
-
-fun parseDetail(id: Int) {
- println("ID: the id i got is $id\ngoodbye!")
-}
-
-fun main(args: Array) {
- // only program name
- if (args.isEmpty()) {
- showUsage()
- return
- } // args.size > 1
-
- // status filter or no filter
- if (args[0] == "list") {
- if (args.size >= 3 && args[1] == "--status") {
- parseList(args[2])
- } else {
- parseList("")
- }
- return
- }
-
- if (args.size >= 2 && args[0] == "detail") {
- val id = args[1].toIntOrNull()
- if (id == null) {
- showUsage()
- return
- } else {
- parseDetail(id)
- }
- return
- }
-
- if (args.size >= 3 && args[0] == "create") {
- parseCreate(args[1], args[2])
- } else {
- showUsage()
- return
- }
-}
\ No newline at end of file
diff --git a/cli/src/Ticket.kt b/cli/src/Ticket.kt
deleted file mode 100644
index bfbe775..0000000
--- a/cli/src/Ticket.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-import java.util.Date
-
-/** ticket model */
-data class Ticket(
- val title: String,
- val description: String,
- val status: String,
- val createdAt: Date,
- val updatedAt: Date
-)
\ No newline at end of file
diff --git a/cli/test/ArgsParseTest.kt b/cli/test/ArgsParseTest.kt
deleted file mode 100644
index 2680c8c..0000000
--- a/cli/test/ArgsParseTest.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Test
-
-class ArgsParseTest {
- @Test
- fun parseCreate() {
-
- }
-
- @Test
- fun parseList() {
-
- }
-
- @Test
- fun parseDetail() {
-
- }
-}
\ No newline at end of file
diff --git a/diagram.xopp b/diagram.xopp
new file mode 100644
index 0000000..b537a6d
Binary files /dev/null and b/diagram.xopp differ