Class: Simple::CLI::DefaultOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/simple/cli/default_options.rb

Overview

A DefaultOptions object holds values for default options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject (readonly)

command



20
21
22
# File 'lib/simple/cli/default_options.rb', line 20

def command
  @command
end

#log_levelObject (readonly)

verbosity (one of ::Logger::WARN, ::Logger::INFO, ::Logger::DEBUG)



12
13
14
# File 'lib/simple/cli/default_options.rb', line 12

def log_level
  @log_level
end

Instance Method Details

#extract!(args:) ⇒ Object

extract default CLI options and the “help” command. Returns a DefaultOptions object



7
8
9
# File 'lib/simple/cli/default_options.rb', line 7

def extract!(args:)
  new args
end

#help?Boolean

The help flag. Is set when

  • running the “help” command

  • when a “-h” or “–help” CLI flag was given.

Returns:

  • (Boolean)


26
27
28
# File 'lib/simple/cli/default_options.rb', line 26

def help?
  @help
end

#verbose?Boolean

returns true if we run in verbose mode.

Returns:

  • (Boolean)


15
16
17
# File 'lib/simple/cli/default_options.rb', line 15

def verbose?
  log_level == ::Logger::DEBUG
end