Build a command-line Application using kotlinx-cli

Build a command-line Application using kotlinx-cli

Since the beginning, writing a command-line app is a challenge in many of the object-oriented languages.

Writing a command-line app is a challenge in many object-oriented languages. Most the object-oriented languages need heavy lifting structure(source code) to run a simple program. Java/Kotlin is one of them. Here, Gradle comes to save us.

Gradle is a framework helping us to create and maintain big applications. Gradle is awesome. However, setting up Gradle is also a tedious task. Here I will show step by step setup to build a scalable CLI(Command Line Interface) tool in Kotlin.

Prerequisite:

  1. Java 1.8 and above
  2. Gradle 5.5.1 and above(Gradle which supports Kotlin DSL)

Step 1: Create a multi-module Gradle project

Create a folder and scaffold the structure with Gradle.

mkdir kotlin-demos #[your project name]
cd kotlin-demos && gradle init

Image for post

Select basic [option 1] or just press enter. After that choose Kotlin[option 2] as build script DSL. You can enter the desired project name. The project name can be different from the folder name.

Once init is done, you can open the project in IntelliJ(IDE). It will sync the Gradle project and you can see available Gradle command on the right side of the IDE.

Image for post

Note: You don’t require IntelliJ for this tutorial. However, IntelliJ is very handy to work with Gradle

tools java kotlin

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

Kotlin vs Java | Kotlin or Java For Android Development | Kotlin And Java Difference

Kotlin and Java have showcased the cut-throat competition in the lastest Android Development. There are a lot of ambiguities amongst developers to choose one, from both. This video will help you to understand the strengths and weaknesses of both with a head to head comparison.

Kotlin vs Java | Java or Kotlin For Android Development

Kotlin vs Java will help you to understand the differences between Kotlin and Java. Time and again, many have misconceptions about both the languages in android development.

Java Online Training | Java Online Course | ITGuru

Our Java Online Training provide you to learn about Java programming and its different features with realty. Our Java Online Course includes live sessions, live projects

Java’s Records vs Kotlin’s Data Classes

How Record classes in Java’s most recent release compares to Kotlin’s data classes.