Sha256: eb89f4477bd38cc2004b8b2d7df54715019ce5740ac9bcf3d55da578799381d4

Contents?: true

Size: 1.2 KB

Versions: 18

Compression:

Stored size: 1.2 KB

Contents

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

<%= run sq(<<-'rb')
    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
  rb
-%>

<%= run "Cl.new('splat').run(%w(left foo bar baz buz))" %>

<%= out '{:cmd=>:left, :one=>["foo", "bar"], :two=>"baz", :three=>"buz"}' %>

<%= run "Cl.new('splat').run(%w(middle foo bar baz buz))" %>

<%= out '{:cmd=>:middle, :one=>"foo", :two=>["bar", "baz"], :three=>"buz"}' %>

<%= run "Cl.new('splat').run(%w(right foo bar baz buz))" %>

<%= out '{: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/_src/args/splat.erb.rb
cl-1.2.4 examples/_src/args/splat.erb.rb
cl-1.2.3 examples/_src/args/splat.erb.rb
cl-1.2.2 examples/_src/args/splat.erb.rb
cl-1.2.1 examples/_src/args/splat.erb.rb
cl-1.2.0 examples/_src/args/splat.erb.rb
cl-1.1.5 examples/_src/args/splat.erb.rb
cl-1.1.4 examples/_src/args/splat.erb.rb
cl-1.1.3 examples/_src/args/splat.erb.rb
cl-1.1.2 examples/_src/args/splat.erb.rb
cl-1.1.1 examples/_src/args/splat.erb.rb
cl-1.1.0 examples/_src/args/splat.erb.rb
cl-1.0.5 examples/_src/args/splat.erb.rb
cl-1.0.4 examples/_src/args/splat.erb.rb
cl-1.0.3 examples/_src/args/splat.erb.rb
cl-1.0.2 examples/_src/args/splat.erb.rb
cl-1.0.1 examples/_src/args/splat.erb.rb
cl-1.0.0 examples/src/args/splat.erb.rb