Class: Toys::StandardMiddleware::AddVerbosityFlags

Inherits:
Object
  • Object
show all
Defined in:
lib/toys/standard_middleware/add_verbosity_flags.rb

Overview

A middleware that provides flags for editing the verbosity.

This middleware adds -v, --verbose, -q, and --quiet flags, if not already defined by the tool. These flags affect the setting of Context::Key::VERBOSITY, and, thus, the logger level.

Constant Summary collapse

DEFAULT_VERBOSE_FLAGS =

Default verbose flags

Returns:

  • (Array<String>)
["-v", "--verbose"].freeze
DEFAULT_QUIET_FLAGS =

Default quiet flags

Returns:

  • (Array<String>)
["-q", "--quiet"].freeze

Instance Method Summary collapse

Constructor Details

#initialize(verbose_flags: true, quiet_flags: true) ⇒ AddVerbosityFlags

Create a AddVerbosityFlags middleware.

Parameters:

  • verbose_flags (Boolean, Array<String>, Proc) (defaults to: true)

    Specify flags to increase verbosity. The value may be any of the following:

    • An array of flags that increase verbosity.
    • The true value to use DEFAULT_VERBOSE_FLAGS. (Default)
    • The false value to disable verbose flags.
    • A proc that takes a tool and returns any of the above.
  • quiet_flags (Boolean, Array<String>, Proc) (defaults to: true)

    Specify flags to decrease verbosity. The value may be any of the following:

    • An array of flags that decrease verbosity.
    • The true value to use DEFAULT_QUIET_FLAGS. (Default)
    • The false value to disable quiet flags.
    • A proc that takes a tool and returns any of the above.


44
45
46
47
# File 'lib/toys/standard_middleware/add_verbosity_flags.rb', line 44

def initialize(verbose_flags: true, quiet_flags: true)
  @verbose_flags = verbose_flags
  @quiet_flags = quiet_flags
end