Sha256: 82f2598e1e08d00ade409b0aace57f877b9f46f8c41f0ab2174ff480dcd1d97d
Contents?: true
Size: 1.92 KB
Versions: 3
Compression:
Stored size: 1.92 KB
Contents
#!/usr/bin/env ruby $: << File.expand_path('lib') <%= run sq(<<-'rb') require 'cl' module Opts class Bool < Cl::Cmd register :bool arg :bool, type: :bool def run p cmd: registry_key, bool: bool end end class Types < Cl::Cmd register :types arg :a, type: :bool arg :b, type: :int arg :c, type: :float arg :d def run p cmd: registry_key, a: a, b: b, c: c, d: d end end end rb -%> <%= run 'Cl.new($0).run(%w(bool on))' %> <%= out '{:cmd=>:bool, :bool=>true}' %> <%= run 'Cl.new($0).run(%w(types true 1 1.2 foo))' %> <%= out '{:cmd=>:types, :a=>true, :b=>1, :c=>1.2, :d=>"foo"}' %> <%= run 'Cl.new($0).run(%w(types true 1 1.2 foo bar))' %> <%= out sq(<<-'str') Too many arguments: true 1 1.2 foo bar (given: 5, allowed: 4) Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options] Arguments: a type: bool b type: int c type: float d type: string Options: --help Get help on this command str %> <%= run 'Cl.new($0).run(%w(types true one 1.2))' %> <%= out sq(<<-'str') Wrong argument type (given: "one", expected: int) Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options] Arguments: a type: bool b type: int c type: float d type: string Options: --help Get help on this command str %> <%= run 'Cl.new($0).run(%w(types true 1 one))' %> <%= out sq(<<-'str') Wrong argument type (given: "one", expected: float) Usage: bin/examples types [a:bool] [b:int] [c:float] [d] [options] Arguments: a type: bool b type: int c type: float d type: string Options: --help Get help on this command str %>
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
travis-cl-1.2.4 | examples/_src/args/opts.erb.rb |
cl-1.2.4 | examples/_src/args/opts.erb.rb |
cl-1.2.3 | examples/_src/args/opts.erb.rb |