Sha256: cad4cda73d91136723161ffa299c81b552bf562935a9f003b00a646df7785bc2

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 KB

Contents

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

require 'cl'

module Splat
  class Left < Cl::Cmd
    register :left

    arg :one, type: :array, splat: true
    args :two, :three

    def run
      p cmd: registry_key, one: one, two: two, three: three
    end
  end

  class Middle < Cl::Cmd
    register :middle

    arg :one
    arg :two, type: :array, splat: true
    arg :three

    def run
      p cmd: registry_key, one: one, two: two, three: three
    end
  end

  class Right < Cl::Cmd
    register :right

    args :one, :two
    arg :three, type: :array, splat: true

    def run
      p cmd: registry_key, one: one, two: two, three: three
    end
  end
end

Cl.new('splat').run(%w(left foo bar baz buz))

# Output:
#
#   {:cmd=>:left, :one=>["foo", "bar"], :two=>"baz", :three=>"buz"}

Cl.new('splat').run(%w(middle foo bar baz buz))

# Output:
#
#   {:cmd=>:middle, :one=>"foo", :two=>["bar", "baz"], :three=>"buz"}

Cl.new('splat').run(%w(right foo bar baz buz))

# Output:
#
#   {:cmd=>:right, :one=>"foo", :two=>"bar", :three=>["baz", "buz"]}

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
travis-cl-1.2.4 examples/args/splat
cl-1.2.4 examples/args/splat
cl-1.2.3 examples/args/splat
cl-1.2.2 examples/args/splat
cl-1.2.1 examples/args/splat
cl-1.2.0 examples/args/splat
cl-1.1.5 examples/args/splat
cl-1.1.4 examples/args/splat
cl-1.1.3 examples/args/splat
cl-1.1.2 examples/args/splat
cl-1.1.1 examples/args/splat
cl-1.1.0 examples/args/splat
cl-1.0.5 examples/args/splat
cl-1.0.4 examples/args/splat
cl-1.0.3 examples/args/splat
cl-1.0.2 examples/args/splat
cl-1.0.1 examples/args/splat
cl-1.0.0 examples/args/splat