class CommandLine::Arguments::Definition

Constants

ENDLESS_PARAMETERS

Attributes

commands[R]
files=[RW]
options[R]
parameters[RW]

Public Class Methods

new(parent) click to toggle source
   # File lib/cli/command_line_arguments.rb
93 def initialize(parent)
94   @parent = parent
95   @options  = {}
96   @commands = {}
97   @parameters = nil
98 end

Public Instance Methods

[](option_name) click to toggle source
    # File lib/cli/command_line_arguments.rb
100 def [](option_name)
101   option_symbol = CommandLine::Option.rewrite(option_name)
102   if the_option = @options.find { |(_, odef)| odef =~ option_symbol }
103     the_option[1]
104   else
105     fail CommandLine::UnknownOption, option_name
106   end
107 end
command(name) { |command_definition| ... } click to toggle source
    # File lib/cli/command_line_arguments.rb
126 def command(name, &_block)
127   command_definition = Definition.new(self)
128   yield(command_definition) if block_given?
129   @commands[CommandLine::Option.rewrite(name)] = command_definition
130 end
has_command?(command) click to toggle source
    # File lib/cli/command_line_arguments.rb
132 def has_command?(command)
133   @commands[CommandLine::Option.rewrite(command)]
134 end
minimum_parameters=(count_specifier) click to toggle source
    # File lib/cli/command_line_arguments.rb
109 def minimum_parameters=(count_specifier)
110   @parameters = count_specifier..ENDLESS_PARAMETERS
111 end
option(name, options = {}) click to toggle source
    # File lib/cli/command_line_arguments.rb
117 def option(name, options = {})
118   clo = CommandLine::Option.new(name, options)
119   @options[clo.name] = clo
120 end
switch(name, switch_alias = nil) click to toggle source
    # File lib/cli/command_line_arguments.rb
122 def switch(name, switch_alias = nil)
123   option(name, alias: switch_alias, parameters: 0)
124 end