Method: Slop.parse
- Defined in:
- lib/slop.rb
.parse(items = ARGV, **config, &block) ⇒ Object
Parse an array of options (defaults to ARGV). Accepts an optional hash of configuration options and block.
Example:
opts = Slop.parse(["-host", "localhost"]) do |o|
o.string '-host', 'a hostname', default: '0.0.0.0'
end
opts.to_hash #=> { host: 'localhost' }
Returns a Slop::Result.
22 23 24 |
# File 'lib/slop.rb', line 22 def self.parse(items = ARGV, **config, &block) Options.new(**config, &block).parse(items) end |