Interface CommandArgument

    • Method Detail

      • getFullName

        String getFullName()
        The default name of the argument. An argument can have more than one name, e.g. --force and -f. Full name can't be null.
        Returns:
        the default name of the argument.
      • getDecoratedName

        default String getDecoratedName()
        The name can contain some tags to advertise status (e.g.: required).
        Returns:
        The default name of the argument with optional tags.
      • getShortName

        String getShortName()
        Short name of the argument if exists.
        Returns:
        short name of the argument or null if the short name doesn't exist.
      • getIndex

        int getIndex()
        If the argument doesn't have a name its value can be found by index. Indexes start with 0. A command could have both a name and an index. In that case, the name is optional. If the command doesn't have a fixed index, the method will return -1.
        Returns:
        the index of the argument.
      • canAppearNext

        boolean canAppearNext​(CommandContext ctx)
                       throws CommandFormatException
        Checks whether the argument can appear on the command given the already present arguments. (Used for tab-completion. Although, often isValueComplete(ParsedOperationRequest req) would be more appropriate.)
        Parameters:
        ctx -
        Returns:
        true if the argument can appear on the command line next, false - otherwise.
        Throws:
        CommandFormatException
      • getValue

        String getValue​(ParsedCommandLine args)
                 throws CommandFormatException
        Returns the value of the argument specified on the command line. If the argument isn't specified the returned value is null. Although, it might throw IllegalArgumentException in case the argument is a required one.
        Parameters:
        args - parsed arguments.
        Returns:
        the value of the argument or null if the argument isn't present or is missing value.
        Throws:
        CommandFormatException
      • getValue

        String getValue​(ParsedCommandLine args,
                        boolean required)
                 throws CommandFormatException
        Returns the value of the argument specified on the command line. If the argument isn't specified and the value is not required null is returned. Otherwise an exception is thrown.
        Parameters:
        args - parsed arguments.
        required - whether the value for this argument is required.
        Returns:
        the value of the argument or null if the argument isn't present and the value is not required.
        Throws:
        CommandFormatException
      • isValueComplete

        boolean isValueComplete​(ParsedCommandLine args)
                         throws CommandFormatException
        Checks whether the value is specified and complete. The value is considered complete only if it is followed by a separator (argument separator, end of argument list but not end-of-content).
        Parameters:
        args - the parsed arguments
        Returns:
        true if the value of the argument is complete, false otherwise.
        Throws:
        CommandFormatException
      • isValueRequired

        boolean isValueRequired()
        Checks whether the argument accepts value.
        Returns:
        true if this argument accepts a value, otherwise false.
      • getValueCompleter

        CommandLineCompleter getValueCompleter()
        Returns the tab-completer for the value.
        Returns:
        tab-completer for the value or null of none available.