Grails - The Command Line



Description

The command line system of the Grails is used for building an application by using APIs and creating the code generation. You can search the repository of a current application by using the below command line:

 
grails <<command name>>

For instance:

The command grails create-controller is used for create a Spring Boot based controller in application to allow interaction with the user. It will create a controller in the project −

grails> create-controller hello
| Rendered controller to grails-app/controllers/helloworld/HelloController.groovy
| Rendered controller to src/test/groovy/helloworld/HelloControllerSpec.groovy
grails>

You can get list of Grails commands by using the grails help command and displays the list as shown below −

D:\Projects\helloworld>grails help
Unmatched argument at index 0: 'help'
Usage: grails [-hvVx] [COMMAND]
Grails CLI command line interface for generating projects and services.
Application generation commands are:

*  create-app NAME
*  create-webapp NAME
*  create-restapi NAME
*  create-plugin NAME
*  create-webplugin NAME

Options:
  -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.

Commands:
  create-app           Creates an application
  create-webapp        Creates an application
  create-plugin        Creates an Grails Plugin
  create-web-plugin    Creates an Grails Web Plugin
  create-restapi       Creates an REST API
  create-interceptor   Creates a Interceptor Class
  create-controller    Creates a Grails Controller
  create-taglib        Creates a Grails TagLib
  create-service       Creates a Service Class
  create-domain-class  Creates a Domain Class

D:\Projects\helloworld>

The command line system includes below concepts:

S.N. Concept & Description
1 Interactive Mode
It runs the JVM and provides the commands for quicker execution.
2 Building with Gradle
It is used for performing some tasks such as compilation, runnings tests etc on your application.
Advertisements