Class Argument


  • public class Argument
    extends java.lang.Object
    A command line argument specification.

    This does not represent a specific argument instance obtained from the user, but information about the possible argument, like his name and description.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Argument.Type
      An argument type.
    • Constructor Summary

      Constructors 
      Constructor Description
      Argument​(java.lang.String option, java.lang.String description, Setting key)
      Constructs a flag or a value argument.
      Argument​(java.lang.String description, Setting key)
      Constructs an unnamed mandatory argument.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getDescription()
      Returns the description used in the help text.
      Setting getKey()
      Returns the key to which the recognized value will be later assigned.
      java.lang.String getOption()
      Returns the option name, e.g.
      Argument.Type getType()
      Returns the argument type.
      java.lang.String getValue()
      Returns the value name suitable for printing in a help text, e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Argument

        public Argument​(java.lang.String description,
                        Setting key)
        Constructs an unnamed mandatory argument.
        Parameters:
        description - the description used in the help text
        key - the key to which the recognized value will be later assigned
      • Argument

        public Argument​(java.lang.String option,
                        java.lang.String description,
                        Setting key)
        Constructs a flag or a value argument.
        Parameters:
        option - the option name, e.g. "o" for "-o"
        description - the description used in the help text
        key - the key to which the recognized value will be later assigned
    • Method Detail

      • getType

        public Argument.Type getType()
        Returns the argument type.
        Returns:
        the type
      • getOption

        public java.lang.String getOption()
        Returns the option name, e.g. "o" for "-o"
        Returns:
        the option name, or an empty string if the argument is unnamed
      • getValue

        public java.lang.String getValue()
        Returns the value name suitable for printing in a help text, e.g. <directory>. The value is automatically extracted from the description.
        Returns:
        the value including the brackets; <value> in case of extraction failure for a mandatory argument; an empty string for a flag
      • getDescription

        public java.lang.String getDescription()
        Returns the description used in the help text.
        Returns:
        the description
      • getKey

        public Setting getKey()
        Returns the key to which the recognized value will be later assigned.
        Returns:
        the key