Class CommandLine


  • public class CommandLine
    extends Object
    The parser transforms a CLI (a model) into an CommandLine. This CommandLine has stored the argument and option values. Only instance of parser should create objects of this type.

    NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.

    • Constructor Detail

      • CommandLine

        public CommandLine​(CommandLine delegate)
      • CommandLine

        public CommandLine​(Object delegate)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • create

        public static CommandLine create​(CLI cli)
        Creates a command line object from the CLI. This object is intended to be used by the parser to set the argument and option values.
        Parameters:
        cli - the CLI definition
        Returns:
        the command line object
      • cli

        public CLI cli()
        Returns:
        the model of this command line object.
      • allArguments

        public List<String> allArguments()
        Returns:
        the ordered list of arguments. Arguments are command line arguments not matching an option.
      • getOptionValue

        public <T> T getOptionValue​(String name)
        Gets the value of an option with the matching name (can be the long name, short name or arg name).
        Parameters:
        name - the name
        Returns:
        the value, null if not set
      • getArgumentValue

        public <T> T getArgumentValue​(String name)
        Gets the value of an argument with the matching name (arg name).
        Parameters:
        name - the name
        Returns:
        the value, null if not set
      • getArgumentValue

        public <T> T getArgumentValue​(int index)
        Gets the value of an argument with the given index.
        Parameters:
        index - the index
        Returns:
        the value, null if not set
      • isFlagEnabled

        public boolean isFlagEnabled​(String name)
        Gets the value of an option marked as a flag.

        Calling this method an a non-flag option throws an IllegalStateException.

        Parameters:
        name - the option name
        Returns:
        true if the flag has been set in the command line, false otherwise.
      • isOptionAssigned

        public boolean isOptionAssigned​(Option option)
        Checks whether or not the given option has been assigned in the command line.
        Parameters:
        option - the option
        Returns:
        true if the option has received a value, otherwise.
      • getRawValues

        @Deprecated
        public List<String> getRawValues​(Option option)
        Deprecated.
        Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.
        Parameters:
        option - the option
        Returns:
        the list of values, empty if none
      • getRawValuesForOption

        public List<String> getRawValuesForOption​(Option option)
        Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.
        Parameters:
        option - the option
        Returns:
        the list of values, empty if none
      • getRawValuesForArgument

        public List<String> getRawValuesForArgument​(Argument argument)
        Gets the raw values of the given argument. Raw values are simple "String", not converted to the argument type.
        Parameters:
        argument - the argument
        Returns:
        the list of values, empty if none
      • getRawValueForOption

        public String getRawValueForOption​(Option option)
        Gets the raw value of the given option. Raw values are the values as given in the user command line.
        Parameters:
        option - the option
        Returns:
        the value, null if none.
      • acceptMoreValues

        public boolean acceptMoreValues​(Option option)
        Checks whether or not the given option accept more values.
        Parameters:
        option - the option
        Returns:
        if the option accepts more values, otherwise.
      • getRawValueForArgument

        public String getRawValueForArgument​(Argument arg)
        Gets the raw value of the given argument. Raw values are the values as given in the user command line.
        Parameters:
        arg - the argument
        Returns:
        the value, null if none.
      • isArgumentAssigned

        public boolean isArgumentAssigned​(Argument arg)
        Checks whether or not the given argument has been assigned in the command line.
        Parameters:
        arg - the argument
        Returns:
        true if the argument has received a value, otherwise.
      • isSeenInCommandLine

        public boolean isSeenInCommandLine​(Option option)
        Checks whether or not the given option has been seen in the user command line.
        Parameters:
        option - the option
        Returns:
        true if the user command line has used the option
      • isValid

        public boolean isValid()
        Checks whether or not the command line is valid, i.e. all constraints from arguments and options have been satisfied. This method is used when the parser validation is disabled.
        Returns:
        true if the current CommandLine object is valid. otherwise.
      • isAskingForHelp

        public boolean isAskingForHelp()
        Checks whether or not the user has passed a "help" option and is asking for help.
        Returns:
        true if the user command line has enabled a "Help" option, otherwise.