svenfuchs/cl

View on GitHub
examples/readme/type

Summary

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

class Add < Cl::Cmd
  register :add

  opt '--active BOOL', type: :boolean
  opt '--retries INT', type: :integer
  opt '--sleep FLOAT', type: :float

  def run
    p active: active.class, retries: retries.class, sleep: sleep.class
  end
end

Cl.new('owners').run(%w(add --active yes --retries 1 --sleep 0.1))

# Output:
#
#   {:active=>TrueClass, :retries=>Integer, :sleep=>Float}