17 Micronaut CLI

    When Micronaut is installed on your computer, you can call the CLI with the command.

    A Micronaut CLI project can be identified by the micronaut-cli.yml file, which will be included at the root of the project (if it was generated via the CLI). This file will include the project’s profile, default package, and other variables. The project’s default package is evaluated based on the project name, for example:

    1. $ mn create-app my-demo-app

    Will result in the following micronaut-cli-yml.

    micronaut-cli.yml

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

    Will result in the following micronaut-cli-yml.

    micronaut-cli.yml

    1. profile: service
    2. defaultPackage: example
    3. testFramework: junit
    4. sourceLanguage: java

    Projects created with the CLI are based on one of several profiles, which consist of a project template (or skeleton), optional features, and profile-specific commands. Commands from a profile typically are specific to the profile application type; for example, the service profile (designed for creation of web service applications) provides the and create-client commands.

    CLI commands typically accept at least one argument, such as the name of the project or controller to generate.

    If you run mn without any arguments, the Micronaut CLI will launch in interactive mode. This is a shell-like mode which allows you to run multiple CLI commands without re-initializing the CLI runtime, and is especially suitable when you are making use of code-generation commands (such as create-controller), creating multiple projects, or simply exploring the features included in the CLI. Tab-completion is enabled in the CLI, enabling you to hit the TAB key to see possible options for a given command or flag.

    1. $ mn
    2. | Starting interactive mode...
    3. | Enter a command name to run. Use TAB for completion:
    4. mn>

    General usage information can be viewed using the help command.

    For details about a specific command, supply the command name after the help command.

    1. mn> help create-app
    2. | Command: create-app
    3. | Description:
    4. Creates an application
    5. create-app [NAME]
    6. ...

    A list of available profiles can be viewed using the list-profiles command.

    1. mn> list-profiles
    2. | Available Profiles
    3. --------------------
    4. base The base profile
    5. cli The cli profile
    6. federation The federation profile
    7. function The function profile
    8. function-aws The function profile for AWS Lambda
    9. kafka The Kafka messaging profile
    10. service The service profile