Package aQute.lib.getopt
Class CommandLine
java.lang.Object
aQute.lib.getopt.CommandLine
Helps parsing command lines. This class takes target object, a primary
command, and a list of arguments. It will then find the command in the target
object. The method of this command must start with a "_" and take an
parameter of Options type. Usually this is an interface that extends Options.
The methods on this interface are options or flags (when they return
boolean).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Assign an option, must handle flags, parameters, and parameters that can happen multiple times.Execute a command in a target object with a set of options and arguments and returns help text if something fails.void
generateDocumentation
(Object target, Appendable out) getCommands
(Object target) Parse a class and return a list of command names<T extends Options>
TgetOptions
(Class<T> specification, List<String> arguments) Parse the options in a command line and return an interface that provides the options from this command line.void
Show all commands in a targetvoid
Show the full help for a given commandvoid
Provide a help text.
-
Constructor Details
-
CommandLine
-
-
Method Details
-
execute
Execute a command in a target object with a set of options and arguments and returns help text if something fails. Errors are reported.- Throws:
Exception
-
generateDocumentation
-
getOptions
public <T extends Options> T getOptions(Class<T> specification, List<String> arguments) throws Exception Parse the options in a command line and return an interface that provides the options from this command line. This will parse up to (and including) -- or an argument that does not start with -- Throws:
Exception
-
assignOptionValue
public void assignOptionValue(Map<String, Object> options, Method m, List<String> args, boolean last) Assign an option, must handle flags, parameters, and parameters that can happen multiple times.- Parameters:
options
- The command line mapm
- the selected method for this optionargs
- the args inputlast
- if this is the last in a multi single character option
-
help
Provide a help text. -
help
Show all commands in a target- Throws:
Exception
-
help
Show the full help for a given command -
getCommands
Parse a class and return a list of command names- Parameters:
target
-- Returns:
- command names
-
getResult
-
subCmd
- Throws:
Exception
-