Sha256: 6b9cebeffd992a0bd8bcc5b8a6db444f5c721bfe409c0867748112b20f61850b

Contents?: true

Size: 869 Bytes

Versions: 3

Compression:

Stored size: 869 Bytes

Contents

#!/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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
travis-cl-1.2.4 examples/readme/requireds
cl-1.2.4 examples/readme/requireds
cl-1.2.3 examples/readme/requireds