(快速參考)

Grails --help 語法

目的

Grails 中的 --help 語法用於請求命令列說明和特定 Grails 命令的詳細資訊。

範例

以下是 Grails 中 --help 語法的部分使用範例

  1. 顯示一般的 Grails 命令列說明

    grails --help
  2. 取得特定 Grails 命令的說明,例如 create-app

    grails create-app --help
  3. 請求 generate-controller 命令的說明

    grails generate-controller --help

說明

Grails 中的 --help 語法是取得 Grails 命令及其使用方式的完整資訊的強大工具。它使用戶能夠了解如何有效執行特定命令,並提供可用選項、引數和使用範例的詳細資訊。

執行 grails --help 時,您將收到 Grails CLI 功能的摘要,包括應用程式產生命令、全域選項和可用命令清單。此輸出旨在協助使用者入門並有效瀏覽 Grails CLI。

使用方式

若要使用 --help 語法,只需將它附加到 Grails 命令,如上述範例所示。這樣會觸發顯示與指定命令相關的詳細說明和資訊。

grails> --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

Grails 開發人員使用特定命令名稱的 --help 語法,可以存取深入的文件,讓使用 Grails 命令變得更容易,並確保在專案中正確使用。以下是使用 --help 搭配 grails create-app 命令的範例

grails> create-app --help
Usage: grails create-app [-hivVx] [--list-features] [-g=GORM Implementation] [--jdk=<javaVersion>]
                         [-s=Servlet Implementation] [-t=TEST] [-f=FEATURE[,FEATURE...]]... [NAME]
Creates an application
      [NAME]            The name of the application to create.
  -f, --features=FEATURE[,FEATURE...]
                        The features to use. Possible values: h2, scaffolding, gorm-hibernate5,
                          spring-boot-starter-jetty, springloaded, spring-boot-starter-tomcat,
                          micronaut-http-client, cache-ehcache, hibernate-validator, postgres,
                          mysql, cache, database-migration, grails-gsp, hamcrest, gorm-mongodb,
                          assertj, mockito, spring-boot-starter-undertow, micronaut-inject-groovy,
                          github-workflow-java-ci, jrebel, testcontainers, sqlserver,
                          grails-console, views-markup, asset-pipeline-grails, views-json,
                          gorm-neo4j, asciidoctor, embedded-mongodb, grails-web-console,
                          logbackGroovy, mongo-sync, shade, geb, properties
  -g, --gorm=GORM Implementation
                        Which GORM Implementation to configure. Possible values: hibernate,
                          mongodb, neo4j.
  -h, --help            Show this help message and exit.
  -i, --inplace         Create a service using the current directory
      --jdk, --java-version=<javaVersion>
                        The JDK version the project should target
      --list-features   Output the available features and their descriptions
  -s, --servlet=Servlet Implementation
                        Which Servlet Implementation to configure. Possible values: none, tomcat,
                          jetty, undertow.
  -t, --test=TEST       Which test framework to use. Possible values: junit, spock.
  -v, --verbose         Create verbose output.
  -V, --version         Print version information and exit.
  -x, --stacktrace      Show full stack trace when exceptions occur.