Sha256: bcd95ee2dba90c2ba46476d2c133b4cc46d7e9163cb82d1cc3d2a7d04a888bfa

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

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

<%= run sq(<<-'rb')
    require 'cl'

    class Required < Cl::Cmd
      arg :one, required: true
      arg :two

      def run
        p cmd: registry_key, one: one, two: two
      end
    end
  rb
-%>

<%= run 'Cl.new($0).run(%w(required one two))' %>

<%= out '{:cmd=>:required, :one=>"one", :two=>"two"}' %>

<%= run 'Cl.new($0).run(%w(required one))' %>

<%= out '{:cmd=>:required, :one=>"one", :two=>nil}' %>

<%= run 'Cl.new($0).run(%w(required))' %>

<%= out sq(<<-'str')
    Missing arguments (given: 0, required: 1)

    Usage: bin/examples required one [two] [options]

    Arguments:

      one         type: string, required: true
      two         type: string

    Options:

      --help      Get help on this command
  str
%>

<%= run 'Cl.new($0).run(%w(required one two three))' %>

<%= out sq(<<-'str')
    Too many arguments (given: 3, allowed: 2)

    Usage: bin/examples required one [two] [options]

    Arguments:

      one         type: string, required: true
      two         type: string

    Options:

      --help      Get help on this command
  str
%>

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cl-1.2.0 examples/_src/args/required.erb.rb
cl-1.1.5 examples/_src/args/required.erb.rb
cl-1.1.4 examples/_src/args/required.erb.rb
cl-1.1.3 examples/_src/args/required.erb.rb
cl-1.1.2 examples/_src/args/required.erb.rb
cl-1.1.1 examples/_src/args/required.erb.rb
cl-1.1.0 examples/_src/args/required.erb.rb
cl-1.0.5 examples/_src/args/required.erb.rb
cl-1.0.4 examples/_src/args/required.erb.rb
cl-1.0.3 examples/_src/args/required.erb.rb
cl-1.0.2 examples/_src/args/required.erb.rb
cl-1.0.1 examples/_src/args/required.erb.rb
cl-1.0.0 examples/src/args/required.erb.rb