File: partialmatch.rb

package info (click to toggle)
ruby-optimist 3.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: ruby: 2,912; makefile: 4
file content (18 lines) | stat: -rwxr-xr-x 562 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby
require_relative '../lib/optimist'

opts = Optimist::options(ARGV, exact_match: false) do
  opt :apple, "An apple"
  opt :apple_sauce, "Cooked apple puree"
  opt :atom, "Smallest unit of ordinary matter"
  opt :anvil, "Heavy metal"
  opt :anteater, "Eats ants"
end
p opts

# $ ./partialmatch.rb  --anv 1
# {:apple=>false, :apple_sauce=>false, :atom=>false, :anvil=>true, :anteater=>false, :help=>false, :anvil_given=>true}
#
# $ ./partialmatch.rb  --an 1
# Error: ambiguous option '--an' matched keys (anvil,anteater).
# Try --help for help.