module TTY::Option::DSL

Public Instance Methods

argument(name, **settings, &block) click to toggle source

Specify an argument

@api public

# File lib/tty/option/dsl.rb, line 40
def argument(name, **settings, &block)
  parameters << Parameter::Argument.create(name.to_sym, **settings, &block)
end
env(name, **settings, &block)
Alias for: environment
environment(name, **settings, &block) click to toggle source

Specify environment variable

@example

EDITOR=vim

@api public

# File lib/tty/option/dsl.rb, line 50
def environment(name, **settings, &block)
  parameters << Parameter::Environment.create(name.to_sym, **settings, &block)
end
Also aliased as: env
flag(name, **settings, &block) click to toggle source

A shortcut to specify flag option

@example

--foo

@api public

# File lib/tty/option/dsl.rb, line 71
def flag(name, **settings, &block)
  defaults = {default: false}
  option(name, **defaults.merge(settings), &block)
end
ignore(*names) click to toggle source

Remove parameter from the parameters definitions list

@api public

# File lib/tty/option/dsl.rb, line 92
def ignore(*names)
  parameters.delete(*names)
end
Also aliased as: skip
keyword(name, **settings, &block) click to toggle source

Specify a keyword

@example

foo=bar

@api public

# File lib/tty/option/dsl.rb, line 61
def keyword(name, **settings, &block)
  parameters << Parameter::Keyword.create(name.to_sym, **settings, &block)
end
opt(name, **settings, &block)
Alias for: option
option(name, **settings, &block) click to toggle source

Specify an option

@example

-f
--foo
--foo bar

@api public

# File lib/tty/option/dsl.rb, line 84
def option(name, **settings, &block)
  parameters << Parameter::Option.create(name.to_sym, **settings, &block)
end
Also aliased as: opt
parameters() click to toggle source

Holds all parameters

@api public

# File lib/tty/option/dsl.rb, line 100
def parameters
  @parameters ||= Parameters.new
end
skip(*names)
Alias for: ignore
usage(**properties, &block) click to toggle source

Holds the usage information

@api public

# File lib/tty/option/dsl.rb, line 29
def usage(**properties, &block)
  @usage ||= Usage.create(**properties, &block).tap do |usage|
               unless usage.command? || usage.no_command?
                 usage.command(dasherize(demodulize(self.name)))
               end
             end
end