{"id":28352208,"url":"https://github.com/enricostara/kotlin-cli-chat","last_synced_at":"2025-08-08T05:42:28.222Z","repository":{"id":53558371,"uuid":"345267741","full_name":"enricostara/kotlin-cli-chat","owner":"enricostara","description":"A personal Kotlin guide for Java developers. A simple chat with a command-line interface only to collect what I have found effective in Kotlin language","archived":false,"fork":false,"pushed_at":"2021-03-24T14:17:21.000Z","size":178,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T01:39:04.595Z","etag":null,"topics":["chat","cli","guide","java","kotlin","kotlin-cli-chat","kotlin-language","kotlin-reference","protocol","reference","topic"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enricostara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-07T05:37:59.000Z","updated_at":"2022-05-21T15:46:42.000Z","dependencies_parsed_at":"2022-09-15T15:23:00.123Z","dependency_job_id":null,"html_url":"https://github.com/enricostara/kotlin-cli-chat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/enricostara/kotlin-cli-chat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enricostara%2Fkotlin-cli-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enricostara%2Fkotlin-cli-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enricostara%2Fkotlin-cli-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enricostara%2Fkotlin-cli-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enricostara","download_url":"https://codeload.github.com/enricostara/kotlin-cli-chat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enricostara%2Fkotlin-cli-chat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269372323,"owners_count":24406271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat","cli","guide","java","kotlin","kotlin-cli-chat","kotlin-language","kotlin-reference","protocol","reference","topic"],"created_at":"2025-05-27T23:05:57.909Z","updated_at":"2025-08-08T05:42:28.199Z","avatar_url":"https://github.com/enricostara.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kotlin-cli-chat\n\nA personal Kotlin guide for Java developers.\n\nThis project implements a simple command-line interface chat just to collect what I found effective in the Kotlin\nlanguage.\n\n## Motivation 🎯\n\nAs a Java developer, I wanted to take a picture of my first impressions of using Kotlin and write this project as a\nguide/reference for myself and other developers who might find it useful.\n\nProbably the Kotlin I wrote will look still boring to a seasoned Kotlin developer. However, it could represent what a\nJava programmer might find interesting to use Kotlin without sacrificing code readability when used in a small or\nmedium-sized team.\n\nFor this reason, I will try to use some idiomatic innovations brought by Kotlin only in cases and in the manner that I\nconsider most effective.\n\n## Implementation 🔩️\n\nA chat application is an opportunity to explore the Kotlin language by implementing different use cases with fun.\n\nThis chat uses a simple command-line interface to perform all required actions, such as create/join a topic, read\nmessages from a topic, send a message, etc. Chat is elementary and will not implement any security such as user\nauthentication and authorization, much less an authoritative server-side validation regarding user and topic handling.\nAll these features and others are beyond the scope of this exercise but could be implemented by forking the project.\n\nThe implementation will purposely have no dependencies on third-party libraries. It will attempt to solve common\nproblems (such as command-line argument mapping) using only the language's expressiveness (like using first-class\nfunctions).\n\nThe code, the comments, and the tests will be the only documentation provided by this project. I have found that Kotlin\nsupports very well in writing unit tests because it is concise. As an exercise, someone could add more tests to increase\ncoverage, and the missing ones could be implemented using a stubbing technique, such as the [MockK](https://mockk.io)\nlibrary.\n\nTo be effective, I'll keep the code as simple as possible, only commenting on the most significant parts. It might be\nbetter to clone the repository or download the zip, open the project with an appropriate IDE\n(like IntelliJ IDEA Community), and go through the code with the natural flow of execution\n(starting point is the `io.kcc.KotlinCliChat` [here](./src/main/java/io/kcc/KotlinCliChat.kt)).\n\nNevertheless, I put all the very basic operational details in this README to [compile and run](#get-started-) the\nproject.\n\n## Communication Protocol ☎️\n\nThe chat default implementation uses a simple file-based communication protocol; therefore, users could use a network\nfile system in local scenarios.\n\nIt may also be that you decide to fork this project and provide a more suitable server-based protocol. This could be\neasy as I will keep the default protocol implementation behind an interface and bound only to the `file`\nschema. For example, a new protocol could be added and implemented by calling an HTTP server using rest calls and\nassociated with the `http` schema instead.\n\n## Get started 🚀\n\nBuild the project with gradle by running the following command from bash in the root directory of your local copy of the\nproject:\n\n```\n./gradlew build\n```\n\nIf the java runtime is already set in the path, run the program by executing the following:\n\n```\n./kcc\n```\n\nYou will get the following:\n\n```\nusage:\n    kcc user\n    kcc host\n    kcc topic\n    kcc \u003c/topic\u003e \u003cmsg\u003e\n    kcc \u003c/topic\u003e\n    kcc \u003c/topic/#\u003e\n    kcc \u003c/topic/user\u003e\n    kcc \u003c/topic/user/#\u003e\n    kcc -h | --help\n    kcc --version\n    \noptions:\n    -h --help            Show this screen\n    --version            Show version\n\n```\n\n### Create the user 💁‍\n\nStart using the chat by accessing the help of the `user` submenu:\n\n```\n./kcc user -h\n```\n\nThe user submenu shows all the operations available to manage your account:\n\n```\nusage:\n    kcc user\n    kcc user new \u003cname\u003e\n    kcc user ren \u003cname\u003e\n    kcc user del\n    kcc user -h | --help\n    \noptions:\n    -h --help   Show this screen\n```\n\nCreate your user by running the following:\n\n```\n./kcc user new your_name\n\nuser 'your_name' has been created.\n```\n\nVerify that the user was created correctly by running:\n\n```\n./kcc user\n \nuser:\n  name: #your_name                \n  topics: no /topics\n```\n\n### Connect the host 📡\n\nShow the help of the `host` submenu:\n\n```\n./kcc host -h\n\nusage:\n    kcc host\n    kcc host new \u003curl\u003e\n    kcc host del\n    kcc host -h | --help\n```\n\nRegister the host using a folder of your choice as the path (the default URL schema will be `file`)\n\n```\nmkdir kcc-db\n./kcc host new ./kcc-db\n\nhost file:./kcc-db has been registered.\n```\n\nShow information about the host you just created:\n\n```\n./kcc host\n\nhost:\n  url: file:./kcc-db\n  schema: file\n  authority: localhost \n  path: ./kcc-db\n```\n\n### Create a new topic 🧨\n\nShow the help of the `topic` submenu:\n\n```\n./kcc topic -h\n\nusage:\n    kcc topic\n    kcc topic new \u003cname\u003e\n    kcc topic join \u003cname\u003e\n    kcc topic leave \u003cname\u003e\n    kcc topic -h | --help\n```\n\nCreate and join a new topic by providing the name:\n\n```\n./kcc topic new jvm-lovers\n\ntopic /jvm-lovers has been created.\ntopic /jvm-lovers has been joined.\n```\n\nShow information about the topics you already joined:\n\n```\n./kcc topic\n\ntopics: \n    - /jvm-lovers       *\n```\n\nAgain from user info:\n\n```\n./kcc user\n\nuser:\n  name: 'your_name'                \n  topics: \n    - /jvm-lovers   \n```\n\n### Read and send messages 🙊🙉\n\nTo send your first message to a topic you already joined, type the following:\n\n```\n./kcc /jvm-lovers Hello by a new kotlin user\n\n/jvm-lovers/your_name \u003e Hello by a new kotlin user\n```\n\nTo read messages from a topic (the default shows the last 10 messages):\n\n```\n./kcc /jvm-lovers\n\n/jvm-lovers/your_name \u003e Hello by a new kotlin user\n```\n\nTo show a specific number of most recent posts, for example only 1 (0 means all):\n\n```\n./kcc /jvm-lovers/1\n```\n\nTo show posts coming from a specific user:\n\n```\n./kcc /jvm-lovers/your_name\n```\n\nTo show posts from a specific user and with a specific number of most recent posts (e.g. 3):\n\n```\n./kcc /jvm-lovers/your_name/3\n```\n\n## About Windows Users 👥\n\nThe project is meant to run in a bash shell and if you are a Windows 10 user you can easily find a guide on \nhow to install the bash shell in your operating system.\n\nFor other versions of Windows you can try running `kcc.bat`, but it was provided without any testing!\n\n## License 💾\nThe project is released under the [MIT license](./LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenricostara%2Fkotlin-cli-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenricostara%2Fkotlin-cli-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenricostara%2Fkotlin-cli-chat/lists"}