4.8.1 Adding Command Help and Options - Reference Documentation
Authors: Andres Almiray
Version: 1.2.0
4.8.1 Adding Command Help and Options
All commands from the standard Griffon distribution are supported ingriffonsh
. Should you choose to integrate your own commands (currently restricted to those delivered by a plugin) then you must generate an additional set of files. The create-script explained in the Scripts section has an on option for doing just that.Say for example you'd want to provide support for a command called create-page
, this is how it can be donegriffon create-script create-page --with-command-support=true
scripts/CreatePage.groovy
test/cli/CreatePageTests.groovy
src/cli/org/codehaus/griffon/cli/shell/help/create-page.txt
griffon help
command is issued, like thisgriffon help create-page
griffonsh help
on the script itself.src/cli/org/codehaus/griffon/cli/shell/command/CreatePageCommand.java src/cli/org/codehaus/griffon/cli/shell/command/create-page.txt
CreatePageCommand.java
) and an optional extended detail section (create-page.txt
). The Java class supports both options and arguments. It's important to note that argument names must match their field names, as suggested by the defualt template shown herepackage org.codehaus.griffon.cli.shell.command;import org.codehaus.griffon.cli.shell.AbstractGriffonCommand; import org.codehaus.griffon.cli.shell.Command; import org.codehaus.griffon.cli.shell.Argument; import org.codehaus.griffon.cli.shell.Option;@Command(scope = "myplugin", name = "create-page", description = "Single line description goes here", detailedDescription = "classpath:create-page.txt") public class CreatePageCommand extends AbstractGriffonCommand { /* @Option(name = "--foo", description = "Description of foo option.", required = false) private String foo; @Argument(index = 0, name = "bar", description = "Description of first argument.", required = false) private String bar; */ }
run-app
command does it@Argument(index = 0, name = "arguments", description = "Optional arguments to be passed to the application.", required = false, multiValued = true) private List<String> arguments;