Sha256: fe9bc34b3f2d8400ae66e0900d1d2e2fee5b8973a3db1a95f3e4d9bf15e47bf2

Contents?: true

Size: 1.11 KB

Versions: 2

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
      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: one two three (given: 3, allowed: 2)

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

    Arguments:

      one         type: string, required
      two         type: string

    Options:

      --help      Get help on this command
  str
%>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cl-1.2.2 examples/_src/args/required.erb.rb
cl-1.2.1 examples/_src/args/required.erb.rb