Using Micronaut CLI to create app, controller

714 views Asked by At

Micronaut CLI is very useful while creating the application, however the command to create a controller is not present in the CLI.

Micronaut Version: 2.0.3

From the micronaut documentation we have a command for profile https://docs.micronaut.io/2.0.0.M3/guide/index.html#cli

$ mn profile-info service
Profile: service
------------------
The service profile

Provided Commands:
--------------------
  create-bean              Creates a singleton bean
  create-client            Creates a client interface
  create-controller        Creates a controller and associated test
  create-job               Creates a job with scheduled method
  create-test              Creates a simple test for the project's testing framework
  create-websocket-client  Creates a Websocket client
  create-websocket-server  Creates a Websocket server
  help                     Prints help information for a specific command


Provided Features:
------------------
...

When I run the command mn profile-info service I get an error as

enter image description here

I have only below options

enter image description here

I am trying to create a controller from the cli

1

There are 1 answers

0
cgrim On

Profiles were only in Micronaut version 1.x. So profile related commands like mn profile-info service are not available in Micronaut version 2.x.

When you create the project end enter the project directory you can use these additional mn commands:

  • feature-diff - Produces the diff of an original project with an original project with additional features.
  • create-job - Creates a job with scheduled method
  • create-client - Creates a client interface
  • create-controller - Creates a controller and associated test
  • create-test - Creates a simple test for the project's testing framework
  • create-bean - Creates a singleton bean
  • create-websocket-client - Creates a Websocket client
  • create-websocket-server - Creates a Websocket server

And you can also see more description of the command when you call it with -h option. For example:

$ mn create-controller -h
Usage: mn create-controller [-fhvVx] CONTROLLER-NAME
Creates a controller and associated test
      CONTROLLER-NAME   The name of the controller to create
  -f, --force           Whether to overwrite existing files
  -h, --help            Show this help message and exit.
  -v, --verbose         Create verbose output.
  -V, --version         Print version information and exit.
  -x, --stacktrace      Show full stack trace when exceptions occur.