Sha256: cc012e9b01651ca376290a21b2739e9d939a4504644b4bb00601636e5f1de206
Contents?: true
Size: 816 Bytes
Versions: 29
Compression:
Stored size: 816 Bytes
Contents
#!/usr/bin/env ruby $: << File.expand_path('lib') require 'cl' class Required < Cl::Cmd arg :one, required: true arg :two def run [registry_key, one: one, two: two] end end def output(cmd, args) args = args.map { |key, value| "#{key}=#{value.inspect}" }.join(' ') puts "Called #{cmd} with #{args}\n\n" end output *Cl.new($0).run(%w(required one two)) # Output: # # Called required with one="one" two="two" output *Cl.new($0).run(%w(required one)) # Output: # # Called required with one="one" two=nil output *Cl.new($0).run(%w(required)) # Output: # # Missing arguments (given: 0, required: 1) # # Usage: args.rb required one [two] output *Cl.new($0).run(%w(required one two three)) # Output: # # Too many arguments (given: 3, allowed: 2) # # Usage: args.rb required one [two]
Version data entries
29 entries across 29 versions & 1 rubygems