Class: P4Tools::CommandOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/p4tools/parsers/command_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ CommandOptions

Returns a new instance of CommandOptions.



6
7
8
9
# File 'lib/p4tools/parsers/command_options.rb', line 6

def initialize(parser)
  @parser = parser
  @show_help = true
end

Instance Attribute Details

#show_helpObject (readonly)

Returns the value of attribute show_help.



4
5
6
# File 'lib/p4tools/parsers/command_options.rb', line 4

def show_help
  @show_help
end

Instance Method Details

#allow_empty_argsObject



23
24
25
# File 'lib/p4tools/parsers/command_options.rb', line 23

def allow_empty_args
  @show_help = false
end

#arg(name, desc = '', options = {}) ⇒ Object

Parameters:

  • name (Symbol)
  • desc (String) (defaults to: '')
  • options (Hash<Symbol, Object>) (defaults to: {})


19
20
21
# File 'lib/p4tools/parsers/command_options.rb', line 19

def arg(name, desc='', options={})
  @parser.opt(name, desc, options)
end

#help(text) ⇒ Object

Parameters:

  • text (String)


12
13
14
# File 'lib/p4tools/parsers/command_options.rb', line 12

def help(text)
  @parser.banner(text)
end

#set(&opts) ⇒ Object



27
28
29
# File 'lib/p4tools/parsers/command_options.rb', line 27

def set(&opts)
  self.instance_eval &opts
end