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:
$ mn create-app my-demo-app
Will result in the following micronaut-cli-yml
.
micronaut-cli.yml
profile: service
defaultPackage: my.demo.app
---
testFramework: junit
sourceLanguage: java
Will result in the following micronaut-cli-yml
.
micronaut-cli.yml
profile: service
defaultPackage: example
testFramework: junit
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.
$ mn
| Starting interactive mode...
| Enter a command name to run. Use TAB for completion:
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.
mn> help create-app
| Command: create-app
| Description:
Creates an application
create-app [NAME]
...
A list of available profiles can be viewed using the list-profiles
command.
mn> list-profiles
| Available Profiles
--------------------
base The base profile
cli The cli profile
federation The federation profile
function The function profile
function-aws The function profile for AWS Lambda
kafka The Kafka messaging profile
service The service profile