Module: CommandKit::Options::VerboseLevel
- Extended by:
- ModuleMethods
- Includes:
- CommandKit::Options
- Defined in:
- lib/command_kit/options/verbose_level.rb
Overview
Defines a -v
,--verbose
option that can be specified multiple times to
increase the verbosity level.
Examples
include CommandKit::Options::VerboseLevel
def run(*argv)
# ...
case verbose
when 1
puts "verbose output"
when 2
puts " extra verbose output"
end
# ...
end
Defined Under Namespace
Modules: ModuleMethods
Constant Summary
Constants included from Printing
Instance Attribute Summary collapse
-
#verbose ⇒ Integer
readonly
The verbosity level.
Attributes included from CommandKit::Options
Attributes included from Parser
Attributes included from CommandName
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Object
Initializes the command and sets #verbose to 0.
-
#verbose? ⇒ Boolean
Determines if verbose mode is enabled.
Methods included from ModuleMethods
Methods included from CommandKit::Options
Methods included from ModuleMethods
Methods included from Parser
#help, #help_options, #main, #on_ambiguous_argument, #on_ambiguous_option, #on_invalid_argument, #on_invalid_option, #on_missing_argument, #on_needless_argument, #on_parse_error, #parse_options
Methods included from Parser::ModuleMethods
Methods included from Printing
#print_error, #print_exception
Methods included from Stdio
#abort, #gets, #print, #printf, #putc, #puts, #readline, #readlines, #stderr, #stdin, #stdout
Methods included from Main
Methods included from Main::ModuleMethods
Methods included from Usage
Methods included from Usage::ModuleMethods
Methods included from Help
Methods included from Help::ModuleMethods
Methods included from CommandName::ModuleMethods
Methods included from Arguments
Methods included from Arguments::ModuleMethods
Instance Attribute Details
#verbose ⇒ Integer (readonly)
The verbosity level.
61 62 63 |
# File 'lib/command_kit/options/verbose_level.rb', line 61 def verbose @verbose end |
Instance Method Details
#initialize(**kwargs) ⇒ Object
Initializes the command and sets #verbose to 0.
69 70 71 72 73 |
# File 'lib/command_kit/options/verbose_level.rb', line 69 def initialize(**kwargs) super(**kwargs) @verbose = 0 end |
#verbose? ⇒ Boolean
Determines if verbose mode is enabled.
82 83 84 |
# File 'lib/command_kit/options/verbose_level.rb', line 82 def verbose? @verbose > 0 end |