Class: Plunger::Runner
- Inherits:
-
Object
- Object
- Plunger::Runner
- Defined in:
- lib/plunger/runner.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
- #run! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
5 6 7 8 |
# File 'lib/plunger/runner.rb', line 5 def initialize(argv) @argv = argv @options = {} end |
Instance Method Details
#run! ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/plunger/runner.rb', line 10 def run! @parser = OptionParser.new do |o| o. = "Usage: plunger #{Command.names.join('|')} [options]" o.separator "" o.separator "Commands:" o.separator "" Command.classes.each do |klass| o.separator " %-20s %s" % [klass.command, klass.description] end o.separator "" o.separator "Push options:" o.on("--initial REVISION", "Initial changeset revision.") { |v| @options[:initial] = v } o.on("--final REVISION", "Final changeset revision.") { |v| @options[:final] = v } o.on("--issue NUMBER", "Issue number to which to add. Defaults to new issue.") { |v| @options[:issue] = v } o.separator "" o.separator "Common options:" o.on_tail("-h", "--help", "Show this message") { puts o; exit } o.on_tail('-v', '--version', "Show version") { puts Plunger::VERSION; exit } end begin @parser.parse!(@argv) rescue OptionParser::InvalidOption => e abort e. end @command = @argv.shift unless Command.names.include?(@command) abort "Unknown command #{@command.inspect}" end Command.autorun Command.run(@command, @options) or abort end |