svenfuchs/cl

View on GitHub
examples/readme/opts

Summary

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

require 'cl'

class Add < Cl::Cmd
  register :add

  opt '--to GROUP', 'Target group to add owners to'

  def run
    p opts: opts, to: to, to?: to?
  end
end

Cl.new('owners').run(%w(add --to one))

# Output:
#
#   {:opts=>{:to=>"one"}, :to=>"one", :to?=>true}

Cl.new('owners').run(%w(add --help))

# Output:
#
#   Usage: owners add [options]
#
#   Options:
#
#     --to GROUP      Target group to add owners to (type: string)
#     --help          Get help on this command