Constructor and Description |
---|
CLIBuilder() |
Modifier and Type | Method and Description |
---|---|
CLI.CLIBuilder |
arg(String name)
Add a named argument.
|
CLI.CLIBuilder |
arg(String name,
CLI.Assoc assoc)
Add a named argument.
|
CLI.CLIBuilder |
arg(String name,
CLI.Parse parse)
Add a named argument.
|
CLI.CLIBuilder |
arg(String name,
CLI.Parse parse,
CLI.Assoc assoc)
Add a named argument.
|
CLI.CLIBuilder |
boolOpt(String shortName,
String longName)
Add a boolean option that enables something.
|
CLI.CLIBuilder |
opt(String shortName,
String longName,
Object defaultValue)
Add an option to be parsed.
|
CLI.CLIBuilder |
opt(String shortName,
String longName,
Object defaultValue,
CLI.Parse parse)
Add an option to be parsed.
|
CLI.CLIBuilder |
opt(String shortName,
String longName,
Object defaultValue,
CLI.Parse parse,
CLI.Assoc assoc)
Add an option to be parsed.
|
CLI.CLIBuilder |
optionalArg(String name)
Add a named argument that is optional.
|
CLI.CLIBuilder |
optionalArg(String name,
CLI.Assoc assoc)
Add a named argument that is optional.
|
CLI.CLIBuilder |
optionalArg(String name,
CLI.Parse parse)
Add a named argument that is optional.
|
CLI.CLIBuilder |
optionalArg(String name,
CLI.Parse parse,
CLI.Assoc assoc)
Add a named argument that is optional.
|
Map<String,Object> |
parse(String... rawArgs)
Parse the command line arguments.
|
public CLI.CLIBuilder opt(String shortName, String longName, Object defaultValue)
Add an option to be parsed.
shortName
- the short single character name of the option (no -
character proceeds it).longName
- the multi character name of the option (no --
characters proceed it).defaultValue
- the value that will be returned of the command if none is given. null if none is given.public CLI.CLIBuilder opt(String shortName, String longName, Object defaultValue, CLI.Parse parse)
Add an option to be parsed.
shortName
- the short single character name of the option (no -
character proceeds it).longName
- the multi character name of the option (no --
characters proceed it).defaultValue
- the value that will be returned of the command if none is given. null if none is given.parse
- an optional function to transform the string to something else. If null a NOOP is used.public CLI.CLIBuilder opt(String shortName, String longName, Object defaultValue, CLI.Parse parse, CLI.Assoc assoc)
Add an option to be parsed.
shortName
- the short single character name of the option (no -
character proceeds it).longName
- the multi character name of the option (no --
characters proceed it).defaultValue
- the value that will be returned of the command if none is given. null if none is given.parse
- an optional function to transform the string to something else. If null a NOOP is used.assoc
- an association command to decide what to do if the option appears multiple times. If null LAST_WINS is used.public CLI.CLIBuilder boolOpt(String shortName, String longName)
Add a boolean option that enables something.
shortName
- the short single character name of the option (no -
character proceeds it).longName
- the multi character name of the option (no --
characters proceed it).public CLI.CLIBuilder arg(String name)
Add a named argument.
name
- the name of the argument.public CLI.CLIBuilder arg(String name, CLI.Assoc assoc)
Add a named argument.
name
- the name of the argument.assoc
- an association command to decide what to do if the argument appears multiple times. If null INTO_LIST is used.public CLI.CLIBuilder arg(String name, CLI.Parse parse)
Add a named argument.
name
- the name of the argument.parse
- an optional function to transform the string to something else. If null a NOOP is used.public CLI.CLIBuilder arg(String name, CLI.Parse parse, CLI.Assoc assoc)
Add a named argument.
name
- the name of the argument.parse
- an optional function to transform the string to something else. If null a NOOP is used.assoc
- an association command to decide what to do if the argument appears multiple times. If null INTO_LIST is used.public CLI.CLIBuilder optionalArg(String name)
Add a named argument that is optional.
name
- the name of the argument.public CLI.CLIBuilder optionalArg(String name, CLI.Assoc assoc)
Add a named argument that is optional.
name
- the name of the argument.assoc
- an association command to decide what to do if the argument appears multiple times. If null INTO_LIST is used.public CLI.CLIBuilder optionalArg(String name, CLI.Parse parse)
Add a named argument that is optional.
name
- the name of the argument.parse
- an optional function to transform the string to something else. If null a NOOP is used.public CLI.CLIBuilder optionalArg(String name, CLI.Parse parse, CLI.Assoc assoc)
Add a named argument that is optional.
name
- the name of the argument.parse
- an optional function to transform the string to something else. If null a NOOP is used.assoc
- an association command to decide what to do if the argument appears multiple times. If null INTO_LIST is used.public Map<String,Object> parse(String... rawArgs) throws Exception
Parse the command line arguments.
rawArgs
- the string arguments to be parsed.Exception
- on any error.Copyright © 2019 The Apache Software Foundation. All rights reserved.