Class: Toys::DSL::Arg

Inherits:
Object
  • Object
show all
Defined in:
lib/toys/dsl/arg.rb

Overview

DSL for an arg definition block. Lets you set arg attributes in a block instead of a long series of keyword arguments.

These directives are available inside a block passed to Tool#required_arg, Tool#optional_arg, or Tool#remaining_args.

Instance Method Summary collapse

Instance Method Details

#accept(accept) ⇒ Toys::DSL::Tool

Set the OptionParser acceptor.



58
59
60
61
# File 'lib/toys/dsl/arg.rb', line 58

def accept(accept)
  @accept = accept
  self
end

#default(default) ⇒ Toys::DSL::Tool

Set the default value.



69
70
71
72
# File 'lib/toys/dsl/arg.rb', line 69

def default(default)
  @default = default
  self
end

#desc(desc) ⇒ Toys::DSL::Tool

Set the short description. See Tool#desc for the allowed formats.



92
93
94
95
# File 'lib/toys/dsl/arg.rb', line 92

def desc(desc)
  @desc = desc
  self
end

#display_name(display_name) ⇒ Toys::DSL::Tool

Set the name of this arg as it appears in help screens.



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

def display_name(display_name)
  @display_name = display_name
  self
end

#long_desc(*long_desc) ⇒ Toys::DSL::Tool

Adds to the long description. This may be called multiple times, and the results are cumulative. See Tool#long_desc for the allowed formats.



105
106
107
108
# File 'lib/toys/dsl/arg.rb', line 105

def long_desc(*long_desc)
  @long_desc += long_desc
  self
end