public class CLI extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
CLI.Assoc |
static class |
CLI.CLIBuilder |
static interface |
CLI.Parse |
Modifier and Type | Field and Description |
---|---|
static CLI.Parse |
AS_INT
Parse function to return an Integer.
|
static CLI.Parse |
AS_STRING
Noop parse function, returns the String.
|
static CLI.Assoc |
FIRST_WINS
First occurrence on the command line is the resulting value.
|
static CLI.Assoc |
INTO_LIST
All values are returned as a List.
|
static CLI.Assoc |
INTO_MAP
All values are returned as a map.
|
static CLI.Assoc |
LAST_WINS
Last occurrence on the command line is the resulting value.
|
Constructor and Description |
---|
CLI() |
Modifier and Type | Method and Description |
---|---|
static CLI.CLIBuilder |
arg(String name)
Add a named argument.
|
static CLI.CLIBuilder |
arg(String name,
CLI.Assoc assoc)
Add a named argument.
|
static CLI.CLIBuilder |
arg(String name,
CLI.Parse parse)
Add a named argument.
|
static CLI.CLIBuilder |
arg(String name,
CLI.Parse parse,
CLI.Assoc assoc)
Add a named argument.
|
static CLI.CLIBuilder |
boolOpt(String shortName,
String longName)
Add a boolean option that enables something.
|
static CLI.CLIBuilder |
opt(String shortName,
String longName,
Object defaultValue)
Add an option to be parsed.
|
static CLI.CLIBuilder |
opt(String shortName,
String longName,
Object defaultValue,
CLI.Parse parse)
Add an option to be parsed.
|
static CLI.CLIBuilder |
opt(String shortName,
String longName,
Object defaultValue,
CLI.Parse parse,
CLI.Assoc assoc)
Add an option to be parsed.
|
static CLI.CLIBuilder |
optionalArg(String name)
Add a named argument that is optional.
|
static CLI.CLIBuilder |
optionalArg(String name,
CLI.Assoc assoc)
Add a named argument that is optional.
|
static CLI.CLIBuilder |
optionalArg(String name,
CLI.Parse parse)
Add a named argument that is optional.
|
static CLI.CLIBuilder |
optionalArg(String name,
CLI.Parse parse,
CLI.Assoc assoc)
Add a named argument that is optional.
|
public static final CLI.Parse AS_INT
Parse function to return an Integer.
public static final CLI.Parse AS_STRING
Noop parse function, returns the String.
public static final CLI.Assoc LAST_WINS
Last occurrence on the command line is the resulting value.
public static final CLI.Assoc FIRST_WINS
First occurrence on the command line is the resulting value.
public static final CLI.Assoc INTO_LIST
All values are returned as a List.
public static final CLI.Assoc INTO_MAP
All values are returned as a map.
public static 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 static 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 static 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 static 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 static CLI.CLIBuilder arg(String name)
Add a named argument.
name
- the name of the argument.public static 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 static 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 static 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 static CLI.CLIBuilder optionalArg(String name)
Add a named argument that is optional.
name
- the name of the argument.public static 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 static 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 static 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.Copyright © 2020 The Apache Software Foundation. All rights reserved.