Module: Argy

Defined in:
lib/argy.rb,
lib/argy/help.rb,
lib/argy/option.rb,
lib/argy/parser.rb,
lib/argy/options.rb,
lib/argy/version.rb,
lib/argy/argument.rb,
lib/argy/parameter.rb

Defined Under Namespace

Classes: Argument, Help, Option, Options, Parameter, ParseError, Parser

Constant Summary collapse

Error =

Base class for all of Argy's errors.

Class.new(StandardError)
CoersionError =

An error that is raised when an option cannot be coerced to the correct type

Class.new(Error)
ValidationError =

An error that is raised when an option is not valid.

Class.new(Error)
VERSION =
"0.2.3"

Class Method Summary collapse

Class Method Details

.new(&block) ⇒ Object

Define a new parser.

Examples:

parser = Argy.new do |o|
  o.argument :input, desc: "the input file"
  o.option :verbose, type: :boolean
end

options = parser.parse(ARGV)

See Also:



37
38
39
# File 'lib/argy.rb', line 37

def self.new(&block)
  Argy::Parser.new(&block)
end

.parse(argv: ARGV, &block) ⇒ Object

Define a parser and return the options in one go.

Examples:

options = Argy.parse do
  o.argument :input, desc: "the input file"
  o.option :verbose, type: :boolean
end

See Also:



48
49
50
# File 'lib/argy.rb', line 48

def self.parse(argv: ARGV, &block)
  new(&block).parse(argv)
end