Class StandardOptions

  • All Implemented Interfaces:
    ArgumentReceiver

    public final class StandardOptions
    extends java.lang.Object
    implements ArgumentReceiver
    Options available to all commands.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEBUG  
      static java.lang.String FORCE_COLOR  
      static java.lang.String HELP  
      static java.lang.String HELP_SHORT  
      static java.lang.String LOGGING  
      static java.lang.String NO_COLOR  
      static java.lang.String QUIET  
      static java.lang.String STACKTRACE  
    • Constructor Summary

      Constructors 
      Constructor Description
      StandardOptions()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AnsiColorFormatter colorSetting()  
      boolean debug()  
      boolean help()  
      java.util.logging.Level logging()  
      boolean quiet()  
      void registerHelp​(HelpPrinter printer)
      Registers help information to the given HelpPrinter.
      boolean stackTrace()  
      boolean testOption​(java.lang.String name)
      Test if the given value-less option is accepted by the receiver.
      java.util.function.Consumer<java.lang.String> testParameter​(java.lang.String name)
      Test if the given parameter that requires a value is accepted by the receiver.
      • Methods inherited from class java.lang.Object

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

      • StandardOptions

        public StandardOptions()
    • Method Detail

      • testOption

        public boolean testOption​(java.lang.String name)
        Description copied from interface: ArgumentReceiver
        Test if the given value-less option is accepted by the receiver.

        If the option is accepted, the receiver should store a stateful value to indicate the option was received, and the CLI will skip the argument for further processing.

        Specified by:
        testOption in interface ArgumentReceiver
        Parameters:
        name - Name of the option to test.
        Returns:
        Returns true if accepted.
      • testParameter

        public java.util.function.Consumer<java.lang.String> testParameter​(java.lang.String name)
        Description copied from interface: ArgumentReceiver
        Test if the given parameter that requires a value is accepted by the receiver.

        If the parameter is accepted, the receiver returns a Consumer that receives the expected value, and it should store a stateful value to allow the value to be later recalled. The CLI will skip the argument for further processing.

        Specified by:
        testParameter in interface ArgumentReceiver
        Parameters:
        name - Name of the parameter to test.
        Returns:
        Returns a consumer if accepted or null if rejected.
      • help

        public boolean help()
      • logging

        public java.util.logging.Level logging()
      • quiet

        public boolean quiet()
      • debug

        public boolean debug()
      • stackTrace

        public boolean stackTrace()