Package org.strassburger.tui4j.command
Class CommandContext
java.lang.Object
org.strassburger.tui4j.command.CommandContext
Represents the context of a command execution, including its name, arguments, and options.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the map of arguments and their corresponding values.<T> TgetArgumentValue(String argumentName, Class<T> type) Retrieves the value of the specified argument by its name.<T> TgetArgumentValue(Argument<T> argument) Retrieves the value of the specified argument.Retrieves the name of the command associated with this context.Retrieves the map of options and their corresponding values.<T> TgetOptionValue(String optionName, Class<T> type) Retrieves the value of the specified option by its name.<T> TgetOptionValue(Option<T> option) Retrieves the value of the specified option.
-
Constructor Details
-
Method Details
-
getCommandName
Retrieves the name of the command associated with this context.- Returns:
- The command name
-
getOptionValue
Retrieves the value of the specified option. If the option is not present in the context, returns its default value.- Type Parameters:
T- The type of the option's value- Parameters:
option- The option whose value is to be retrieved- Returns:
- The value of the option, or its default value if not set
-
getOptionValue
Retrieves the value of the specified option by its name.- Type Parameters:
T- The type of the option's value- Parameters:
optionName- The name of the option (long or short)type- The class type of the option's value- Returns:
- The value of the option, or null if not found
-
getArgumentValue
Retrieves the value of the specified argument.- Type Parameters:
T- The type of the argument's value- Parameters:
argument- The argument whose value is to be retrieved- Returns:
- The value of the argument
-
getArgumentValue
Retrieves the value of the specified argument by its name.- Type Parameters:
T- The type of the argument's value- Parameters:
argumentName- The name of the argumenttype- The class type of the argument's value- Returns:
- The value of the argument, or null if not found
-
getOptions
Retrieves the map of options and their corresponding values.- Returns:
- A map of Option instances to their values
-
getArguments
Retrieves the map of arguments and their corresponding values.- Returns:
- A map of Argument instances to their values
-