svenfuchs/cl

View on GitHub
examples/heroku

Summary

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

require 'cl'

module Heroku
  module Apps
    class Create < Cl::Cmd
      register 'apps:create'

      arg :name, required: true

      opt '-o', '--org ORG'

      def run
        p cmd: registry_key, args: args, opts: opts
      end
    end

    class List < Cl::Cmd
      register 'apps:info'

      opt '-a', '--app APP'

      def run
        p cmd: registry_key, args: args, opts: opts
      end
    end
  end
end

Cl.new('heroku').run(%w(apps:create name -o org))
# or:
#
#   Cl.new('heroku').run(%w(apps create name -o org))

# Output:
#
#   {:cmd=>:"apps:create", :args=>["name"], :opts=>{:org=>"org"}}

Cl.new('heroku').run(%w(apps:info -a app))
# or:
#
#   Cl.new('heroku').run(%w(apps info -a app))

# Output:
#
#   {:cmd=>:"apps:info", :args=>[], :opts=>{:app=>"app"}}