Create-Cli-App

The create-cli-app command will generate a Micronaut command line application project, with optional flags to specify language, test framework, features, profile, and build tool. By default the project will have the picocli feature to support command line option parsing, and the cli profile to easily create additional commands. The project will include a *Command class (based on the project name - e.g., hello-world will generate HelloWorldCommand), and an associated test which will instantiate the command and verify that it can parse command line options.

Table 3. Create-Cli-App Flags
FlagDescriptionExample

-l, —lang

Language to use for the command (one of java, groovy, kotlin - default is java)

—lang groovy

-t, —test

Test framework to use for the command (one of junit, spock - default is junit)

—test spock

-b, —build

Build tool (one of gradle, maven - default is gradle)

—build maven

-p, —profile

Profile to use for the project (default is cli)

—profile function-aws

-f, —features

Features to use for the project, comma-separated (picocli is included by default)

  1. features http-client,jdbc-hikari

or

  1. -f http-client -f jdbc-hikari

-i, —inplace

If present, generates the project in the current directory (project name is optional if this flag is set)

—inplace

Once created, the application can be started using the *Command class, or the appropriate build tool task.

Starting a Gradle project

  1. $ ./gradlew run

Starting a Maven project

  1. $ ./mvnw compile exec:exec

Language/Test Features

By default, create-cli-app will generate a Java application, with JUnit configured as the test framework. The language and test framework settings for a given project are stored as the testFramework and sourceLanguage properties in the micronaut-cli.yml file, as shown below:

micronaut-cli.yml

  1. profile: cli
  2. defaultPackage: my.demo.app
  3. ---
  4. testFramework: junit
  5. sourceLanguage: java

Groovy

To create an app with Groovy & Spock support, supply the appropriate features via the lang and test flags:

  1. $ mn create-cli-app my-groovy-app --lang=groovy --test=spock

This will include the Groovy & Spock dependencies in your project, and write the appropriates values in micronaut-cli.yml.

Kotlin

To create an app with Kotlin & KotlinTest support, supply the appropriate features via the lang and test flags:

  1. $ mn create-cli-app my-kotlin-app --lang=kotlin --test=kotlintest

This will include the Kotlin & KotlinTest dependencies in your project, and write the appropriates values in micronaut-cli.yml.

Build Tool

By default create-cli-app will create a Gradle project, with a build.gradle file at the root of the project directory. To create an app using the Maven build tool, supply the appropriate option via the build flag:

  1. $ mn create-cli-app my-maven-app --build maven