Class: Optitron::Dsl::RootParserDsl

Inherits:
AbstractDsl show all
Defined in:
lib/optitron/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractDsl

#arg, #configure_with, #opt

Constructor Details

#initialize(parser) ⇒ RootParserDsl

Returns a new instance of RootParserDsl.


80
81
82
83
# File 'lib/optitron/dsl.rb', line 80

def initialize(parser)
  @target = parser
  @unclaimed_opts = []
end

Instance Attribute Details

#unclaimed_optsObject (readonly)

Returns the value of attribute unclaimed_opts


79
80
81
# File 'lib/optitron/dsl.rb', line 79

def unclaimed_opts
  @unclaimed_opts
end

Instance Method Details

#cmd(name, description = nil, opts = nil, &blk) ⇒ Object


100
101
102
103
104
# File 'lib/optitron/dsl.rb', line 100

def cmd(name, description = nil, opts = nil, &blk)
  command_option = Option::Cmd.new(name, description, opts)
  CmdParserDsl.new(self, command_option).configure_with(&blk) if blk
  @target.commands << [name, command_option]
end

#help(desc = "Print help message") ⇒ Object


85
86
87
88
89
90
91
92
93
94
# File 'lib/optitron/dsl.rb', line 85

def help(desc = "Print help message")
  configure_with {
    opt 'help', desc, :short_name => '?', :suppress_no => true, :run => proc{ |value, response|
      if value
        puts @target.help
        exit(0)
      end
    }
  }
end

#short_optsObject


96
97
98
# File 'lib/optitron/dsl.rb', line 96

def short_opts
  @target.short_opts
end