diff --git a/cli/.gitignore b/cli/.gitignore new file mode 100644 index 0000000..3ddbf4c --- /dev/null +++ b/cli/.gitignore @@ -0,0 +1,32 @@ +### 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 new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/cli/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/cli/.idea/codeStyles/Project.xml b/cli/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..1bec35e --- /dev/null +++ b/cli/.idea/codeStyles/Project.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/cli/.idea/codeStyles/codeStyleConfig.xml b/cli/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/cli/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/cli/.idea/inspectionProfiles/Project_Default.xml b/cli/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..df543e3 --- /dev/null +++ b/cli/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/cli/.idea/kotlinc.xml b/cli/.idea/kotlinc.xml new file mode 100644 index 0000000..3777884 --- /dev/null +++ b/cli/.idea/kotlinc.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/cli/.idea/libraries/KotlinJavaRuntime.xml b/cli/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..d777bf6 --- /dev/null +++ b/cli/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cli/.idea/misc.xml b/cli/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/cli/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cli/.idea/modules.xml b/cli/.idea/modules.xml new file mode 100644 index 0000000..7f2948e --- /dev/null +++ b/cli/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/cli/.idea/vcs.xml b/cli/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/cli/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cli/cli.iml b/cli/cli.iml new file mode 100644 index 0000000..8dfb729 --- /dev/null +++ b/cli/cli.iml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cli/src/Main.kt b/cli/src/Main.kt new file mode 100644 index 0000000..bf2b0ee --- /dev/null +++ b/cli/src/Main.kt @@ -0,0 +1,69 @@ +/** + * TICKETS + * + * a Linux cli for the mini ticket system written in C + * features: + * - create a ticket + * `tickets create <description>` + * - list all tickets (or filter by status) + * `tickets list --status=(open|in_progress|closed)` + * - detail of one ticket + * `tickets detail <id>` + */ + +fun showUsage() { + println("usage:\n" + + " tickets create <title> <description>\n" + + " tickets list --status (open|in_progress|closed)\n" + + " tickets detail <id>\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<String>) { + // 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 new file mode 100644 index 0000000..bfbe775 --- /dev/null +++ b/cli/src/Ticket.kt @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..2680c8c --- /dev/null +++ b/cli/test/ArgsParseTest.kt @@ -0,0 +1,19 @@ +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