class Twigg::Command
Constants
- EASTER_EGGS
- PUBLIC_SUBCOMMANDS
Subcommands, in the order they should appear in the help output.
- SUBCOMMANDS
Public Class Methods
new(*args)
click to toggle source
# File lib/twigg/command.rb, line 93 def initialize(*args) # the -c/--config option is applied immediately on load (see # twigg/lib/twigg.rb); ensure it gets consumed consume_option(%w[-c --config], args) @debug = true if args.delete('-d') || args.delete('--debug') @verbose = true if args.delete('-v') || args.delete('--verbose') @args = args end
run(subcommand, *args)
click to toggle source
# File lib/twigg/command.rb, line 25 def run(subcommand, *args) Help.new('usage').run! unless SUBCOMMANDS.include?(subcommand) if args.include?('-h') || args.include?('--help') Help.new(subcommand).run exit end begin send(subcommand, *args) rescue => e raise if args.include?('-d') || args.include?('--debug') error e.message stderr '[run with -d or --debug flag to see full stack trace]' die end end
Private Class Methods
app(*args)
click to toggle source
# File lib/twigg/command.rb, line 53 def app(*args) with_dependency('twigg-app') { App.new(*args).run } end
gerrit(*args)
click to toggle source
# File lib/twigg/command.rb, line 57 def gerrit(*args) with_dependency('twigg-gerrit') { Gerrit.new(*args).run } end
git(*args)
click to toggle source
# File lib/twigg/command.rb, line 61 def git(*args) Git.new(*args).run end
github(*args)
click to toggle source
# File lib/twigg/command.rb, line 65 def github(*args) GitHub.new(*args).run end
help(*args)
click to toggle source
# File lib/twigg/command.rb, line 69 def help(*args) Help.new(*args).run end
ignore(args)
click to toggle source
# File lib/twigg/command.rb, line 46 def ignore(args) if args.any? warn "unsupported extra argument#{'s' if args.size > 1} " \ "#{args.inspect} ignored" end end
init(*args)
click to toggle source
# File lib/twigg/command.rb, line 73 def init(*args) Init.new(*args).run end
pivotal(*args)
click to toggle source
# File lib/twigg/command.rb, line 77 def pivotal(*args) with_dependency('twigg-pivotal') { Pivotal.new(*args).run } end
russian(*args)
click to toggle source
# File lib/twigg/command.rb, line 81 def russian(*args) Russian.new(*args).run end
stats(*args)
click to toggle source
# File lib/twigg/command.rb, line 85 def stats(*args) Stats.new(*args).run end
Public Instance Methods
run()
click to toggle source
Abstract implementation of a “run” method; subclasses are expected to override this method.
# File lib/twigg/command.rb, line 111 def run raise NotImplementedError end
run!()
click to toggle source
Run and then die.
# File lib/twigg/command.rb, line 104 def run! run die end