Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swiftsoftwaregroup/cli-kt
Template for Command Line Interface (CLI) tool in Kotlin
https://github.com/swiftsoftwaregroup/cli-kt
cli kotlin
Last synced: 14 days ago
JSON representation
Template for Command Line Interface (CLI) tool in Kotlin
- Host: GitHub
- URL: https://github.com/swiftsoftwaregroup/cli-kt
- Owner: swiftsoftwaregroup
- License: apache-2.0
- Created: 2024-09-15T17:45:14.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T22:54:44.000Z (about 2 months ago)
- Last Synced: 2024-10-10T15:01:17.354Z (about 1 month ago)
- Topics: cli, kotlin
- Language: Kotlin
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cli-kt
Template for Command Line Interface (CLI) tool in Kotlin
## Setup for macOS
### Xcode Command Line Tools
Install Command Line Tools (CLT) for Xcode:
```bash
xcode-select --install
```### Homebrew
Install [Homebrew](https://brew.sh/):
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```### SDKMAN!
Install:
```bash
curl -s "https://get.sdkman.io" | bash
source ~/.sdkman/bin/sdkman-init.sh
```Test:
```bash
sdk list java
```Configure:
```bash
# open config file
sdk config# set:
# sdkman_auto_answer=true# save the file
```## Work on macOS
Configure project:
```bash
source configure.sh
```Open the project in Visual Studio Code:
```bash
code .
```### Build
```bash
./gradlew build
```### Run
```bash
echo "John" > name.txt./gradlew run --args="greet name.txt"
./gradlew run --args="greet --language es name.txt"
./gradlew run --args="greet -l bg name.txt"
```### Run as JAR
Build JAR:
```bash
./gradlew shadowJar
```Run as JAR:
```bash
echo "John" > name.txtjava -jar build/libs/cli-kt.jar greet name.txt
java -jar build/libs/cli-kt.jar greet --language es name.txt
java -jar build/libs/cli-kt.jar greet -l bg name.txt
```### Test
Run all tests:
```bash
./gradlew testGreetCommand Tests
generateGreeting function
✔ should generate correct greetings for different languages
GreetCommand execution
✔ should greet in English by default
✔ should handle non-existent file
✔ should greet in Spanish when specified
✔ should greet in Bulgarian when specifiedreadNameFromFile function
✔ should read name correctly from file
6 passing (698ms)
```Run specific test:
```bash
./gradlew test --tests "GreetCommandTest\$GenerateGreetingTests.testGenerateGreeting"GreetCommand Tests
generateGreeting function
✔ should generate correct greetings for different languages
1 passing (558ms)
```