Package software.amazon.smithy.cli
Class Arguments
java.lang.Object
software.amazon.smithy.cli.Arguments
Container for parsed command line arguments meant to be queried by Commands.
Values parsed for command line arguments are canonicalized to the
long-form of an argument if available. This means that an argument
with a short name of "-h" and a long name of "--help" would be made
available in an Arguments
instance as "--help" and not "-h".
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
Checks if a canonicalized argument name was provided.int
hashCode()
Gets an argument by name or throws if not present.Gets an argument by name or return a default value if not found.Gets the list of positional arguments that came after named arguments.repeatedParameter
(String arg) Gets a repeated argument by name or throws if not present.repeatedParameter
(String arg, List<String> defaultValues) Gets a repeated argument by name or returns a default list if not found.toString()
-
Constructor Details
-
Arguments
-
-
Method Details
-
has
Checks if a canonicalized argument name was provided.This method should be used for checking if a option is set rather than calling
parameter(java.lang.String)
since that method throws when an argument cannot be found.- Parameters:
arg
- Argument to check for (e.g., "--help").- Returns:
- Returns true if the argument was set.
-
parameter
Gets an argument by name or throws if not present.Returns the first value if the argument is repeated.
- Parameters:
arg
- Argument to get (e.g., "-h", "--help").- Returns:
- Returns the value of the matching argument.
- Throws:
CliError
- if the argument cannot be found or if the arg is a option.
-
parameter
Gets an argument by name or return a default value if not found.- Parameters:
arg
- Argument to get (e.g., "-h", "--help").defaultValue
- Default value to return if not found.- Returns:
- Returns the value of the matching argument.
-
repeatedParameter
Gets a repeated argument by name or throws if not present.- Parameters:
arg
- Argument to retrieve (e.g., "--help").- Returns:
- Returns a list of values for the argument.
- Throws:
CliError
- if the argument cannot be found or if the arg is a option.
-
repeatedParameter
Gets a repeated argument by name or returns a default list if not found.- Parameters:
arg
- Argument to retrieve (e.g., "--help").defaultValues
- Default list of values to return if not found.- Returns:
- Returns a list of values for the argument.
-
positionalArguments
Gets the list of positional arguments that came after named arguments.- Returns:
- Returns the trailing positional arguments.
-
toString
-
equals
-
hashCode
public int hashCode()
-