Sha256: cbd5f4ea8e0c7b967c7fd8d8a61dceba76130771d39e9f7d471190e304fe9bcb

Contents?: true

Size: 698 Bytes

Versions: 29

Compression:

Stored size: 698 Bytes

Contents

#!/usr/bin/env ruby
$: << File.expand_path('lib')

require 'cl'

class Opts < Cl::Cmd
  opt '-p', '--path PATH'
  opt '-v', '--verbose'

  def run
    [registry_key, args, opts]
  end
end

def output(cmd, args, opts)
  puts "Called #{cmd} with args=#{args} opts=#{opts}\n\n"
end

output *Cl.new($0).run(%w(opts -p path -v))

# Output:
#
#   Called cast with args=[] opts={:path=>"path", :verbose=>true}

output *Cl.new($0).run(%w(opts --path path --verbose))

# Output:
#
#   Called cast with args=[] opts={:path=>"path", :verbose=>true}

output *Cl.new($0).run(%w(opts one -p path two -v three))

# Output:
#
#   Called cast with args=["one", "two", "three"] opts={:path=>"path", :verbose=>true}

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
cl-0.1.28 examples/args/opts
cl-0.1.27 examples/args/opts
cl-0.1.26 examples/args/opts
cl-0.1.25 examples/args/opts
cl-0.1.24 examples/args/opts
cl-0.1.23 examples/args/opts
cl-0.1.22 examples/args/opts
cl-0.1.21 examples/args/opts
cl-0.1.20 examples/args/opts
cl-0.1.19 examples/args/opts
cl-0.1.18 examples/args/opts
cl-0.1.17 examples/args/opts
cl-0.1.16 examples/args/opts
cl-0.1.15 examples/args/opts
cl-0.1.14 examples/args/opts
cl-0.1.13 examples/args/opts
cl-0.1.12 examples/args/opts
cl-0.1.11 examples/args/opts
cl-0.1.10 examples/args/opts
cl-0.1.9 examples/args/opts