Skip to content

orchestr7/kotlin-mpp-cli

Repository files navigation

License Build and test Hits-of-Code GitHub repo size Run deteKT Run diKTat

Want to write a native cli application, but do not want to write it in C/C++? Do not want users to think about installing SDK (like Python, JDK/JRE, etc.) and related dependencies? You can easily and quickly write your application using Kotlin MPP and have Native executables using this template! All boilerplate is already done in this template, so no need to spend days on the boring work and on the setup of environment, all you need - to implement business logic.

We did this boring work for you, so don't forget to give a star to this project to save it in your list! ⭐

What's inside

✅ Github actions build/release scripts to Central and Github Releases
✅ Gradle build/release tasks for Kotlin MPP
✅ Code analysis enabled with a full GitHub integration
✅ Junit testing report integration with Github
✅ Nice and easy code generation for cli from a config file
✅ Application that is based on kotlinx.cli
✅ Utility methods for a cli application

How to use it

  1. Create a new repository based on this template using Github: Use this template -> Create a new repository;
  2. Replace everywhere 'kotlin-mpp-cli' to your name of the project;
  3. Replace 'com.akuleshov7.cli' to your package domain name in code and directory names (!);
  4. Run CliPropertiesTest.kt on JVM to check that everything is setup correctly;
  5. Add your cli options to buildSrc/src/main/resources/config-options.json (and config-arguments.json);
  6. Once the project is built (./gradlew build), OptionsTable.md, CliProperties.kt files will be generated;
  7. Implement the business logic of your application in core module (BusinessLogic class);
  8. Do not forget to change Publishing configuration (license, git url, etc.) in PublishingConfiguration.kt;
  9. Add publishing credentials for Maven central to GitHub: OSSRH_USERNAME, OSSRH_PASSWORD, GPG_SEC, GPG_PASSWORD. Read more here.

Useful scripts

  1. To build project: ./gradlew build
  2. To run diktat auto-fix: ./gradlew diktatFix
  3. To run detekt: ./gradlew detektAll

Supported platforms

Main part of the code is written in Kotlin common module. This means that it can be built for each and every Kotlin native platform. However, to reduce the scope, kotlin-mpp-cli now supports only the following platforms:

  • jvm
  • mingwx64
  • linuxx64
  • macosx64
  • macosArm64 (M1+)

🌐 latest supported Kotlin version: 1.8

Small notes about an architecture of this project

Main modules:

  • cli: contains main method and cli-related things
  • common: common logic like data models and so on
  • core: core business logic and a framework (if any)

Intellij IDEA problems

JB still has a limited support to MPP projects, so you probably will have problems while indexing of this project in IDE. Known problems:

  • CliProperties probably can be ignored by indexing and marked as unknown dependency;
  • main method is not runnable out of the box in IDE, but you can run it using run-configuration.

Acknowledgement

Special thanks to those developers who help us to make this project: @akuleshov7 @petertrr

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages