examples/readme/requireds
#!/usr/bin/env ruby
$: << File.expand_path('lib')
class Add < Cl::Cmd
register :add
# read DNF, i.e. "token OR user AND pass
required :token, [:user, :pass]
opt '--token TOKEN'
opt '--user NAME'
opt '--pass PASS'
def run
p token: token, user: user, pass: pass
end
end
Cl.new('owners').run(%w(add --token token))
# Output:
#
# {:token=>"token", :user=>nil, :pass=>nil}
Cl.new('owners').run(%w(add --user user --pass pass))
# Output:
#
# {:token=>nil, :user=>"user", :pass=>"pass"}
Cl.new('owners').run(%w(add))
# Output:
#
# Missing options: token, or user and pass
#
# Usage: owners add [options]
#
# Options:
#
# Either token, or user and pass are required.
#
# --token TOKEN type: string
# --user NAME type: string
# --pass PASS type: string
# --help Get help on this command