Package picocli
Class AutoComplete
- java.lang.Object
-
- picocli.AutoComplete
-
public class AutoComplete extends java.lang.ObjectStand-alone tool that generates bash auto-complete scripts for picocli-based command line applications.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAutoComplete.GenerateCompletionCommand that generates a Bash/ZSH completion script for its top-level command.
-
Field Summary
Fields Modifier and Type Field Description static intEXIT_CODE_COMMAND_SCRIPT_EXISTSExit code of this application when the specified command script exists (2).static intEXIT_CODE_COMPLETION_SCRIPT_EXISTSExit code of this application when the specified completion script exists (3).static intEXIT_CODE_EXECUTION_ERRORExit code of this application when an exception was encountered during operation (4).static intEXIT_CODE_INVALID_INPUTExit code of this application when the specified command line arguments are invalid (1).static intEXIT_CODE_SUCCESSNormal exit code of this application (0).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbash(java.lang.String scriptName, java.io.File out, java.io.File command, CommandLine commandLine)Generates source code for an autocompletion bash script for the specified picocli-based application, and writes this script to the specifiedoutfile, and optionally writes an invocation script to the specifiedcommandfile.static java.lang.Stringbash(java.lang.String scriptName, CommandLine commandLine)Generates and returns the source code for an autocompletion bash script for the specified picocli-based application.static intcomplete(CommandLine.Model.CommandSpec spec, java.lang.String[] args, int argIndex, int positionInArg, int cursor, java.util.List<java.lang.CharSequence> candidates)static voidmain(java.lang.String... args)Generates a bash completion script for the specified command class.
-
-
-
Field Detail
-
EXIT_CODE_SUCCESS
public static final int EXIT_CODE_SUCCESS
Normal exit code of this application (0).- See Also:
- Constant Field Values
-
EXIT_CODE_INVALID_INPUT
public static final int EXIT_CODE_INVALID_INPUT
Exit code of this application when the specified command line arguments are invalid (1).- See Also:
- Constant Field Values
-
EXIT_CODE_COMMAND_SCRIPT_EXISTS
public static final int EXIT_CODE_COMMAND_SCRIPT_EXISTS
Exit code of this application when the specified command script exists (2).- See Also:
- Constant Field Values
-
EXIT_CODE_COMPLETION_SCRIPT_EXISTS
public static final int EXIT_CODE_COMPLETION_SCRIPT_EXISTS
Exit code of this application when the specified completion script exists (3).- See Also:
- Constant Field Values
-
EXIT_CODE_EXECUTION_ERROR
public static final int EXIT_CODE_EXECUTION_ERROR
Exit code of this application when an exception was encountered during operation (4).- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(java.lang.String... args)
Generates a bash completion script for the specified command class.- Parameters:
args- command line options. Specify at least thecommandLineFQCNmandatory parameter, which is the fully qualified class name of the annotated@Commandclass to generate a completion script for. Other parameters are optional. Specify-hto see details on the available options.
-
bash
public static void bash(java.lang.String scriptName, java.io.File out, java.io.File command, CommandLine commandLine) throws java.io.IOExceptionGenerates source code for an autocompletion bash script for the specified picocli-based application, and writes this script to the specifiedoutfile, and optionally writes an invocation script to the specifiedcommandfile.- Parameters:
scriptName- the name of the command to generate a bash autocompletion script forcommandLine- theCommandLineinstance for the command line applicationout- the file to write the autocompletion bash script source code tocommand- the file to write a helper script to that invokes the command, ornullif no helper script file should be written- Throws:
java.io.IOException- if a problem occurred writing to the specified files
-
bash
public static java.lang.String bash(java.lang.String scriptName, CommandLine commandLine)Generates and returns the source code for an autocompletion bash script for the specified picocli-based application.- Parameters:
scriptName- the name of the command to generate a bash autocompletion script forcommandLine- theCommandLineinstance for the command line application- Returns:
- source code for an autocompletion bash script
-
complete
public static int complete(CommandLine.Model.CommandSpec spec, java.lang.String[] args, int argIndex, int positionInArg, int cursor, java.util.List<java.lang.CharSequence> candidates)
-
-