examples/gem
#!/usr/bin/env ruby
$: << File.expand_path('lib')
require 'cl'
module Gem
module Release
module Cmds
class Release < Cl::Cmd
register 'release'
arg :gemspec
opt '-h', '--host HOST', 'Push to a compatible host other than rubygems.org'
opt '-k', '--key KEY', 'Rubygems API key to use'
opt '-q', '--quiet', 'Silence output'
def run
p cmd: registry_key, args: args, opts: opts
end
end
class Bump < Cl::Cmd
register 'bump'
opt '-v', '--version VERSION', 'The version to bump to [1.1.1|major|minor|patch|pre|rc|release]'
opt '--[no-]commit', 'Bump the version, but do not commit'
def run
p cmd: registry_key, args: args, opts: opts
end
end
end
end
end
Cl.new('gem').run(%w(help))
# Output:
#
# Type "gem help COMMAND [SUBCOMMAND]" for more details:
#
# gem release [gemspec] [options]
# gem bump [options]
Cl.new('gem').run(%w(help release))
# or:
#
# Cl.new('gem').run(%w(release --help)))
# Cl.new('gem').run(%w(release -h)))
#
# Output:
#
# Usage: gem release [gemspec] [options]
#
# Arguments:
#
# gemspec type: string
#
# Options:
#
# -h --host HOST Push to a compatible host other than rubygems.org (type: string)
# -k --key KEY Rubygems API key to use (type: string)
# -q --[no-]quiet Silence output
# --help Get help on this command
Cl.new('gem').run(%w(help bump))
# or:
#
# Cl.new('gem').run(%w(bump --help)))
# Cl.new('gem').run(%w(bump -h)))
#
# Output:
#
# Usage: gem bump [options]
#
# Options:
#
# -v --version VERSION The version to bump to [1.1.1|major|minor|patch|pre|rc|release] (type: string)
# --[no-]commit Bump the version, but do not commit
# --help Get help on this command
Cl.new('gem').run(%w(bump -v 1.1.1))
# Output:
#
# {:cmd=>:bump, :args=>[], :opts=>{:version=>"1.1.1"}}
Cl.new('gem').run(%w(release foo.gemspec -h host -k key -q))
# Output:
#
# {:cmd=>:release, :args=>["foo.gemspec"], :opts=>{:host=>"host", :key=>"key", :quiet=>true}}