Class: PivotalToTrello::Runner
- Inherits:
-
Object
- Object
- PivotalToTrello::Runner
- Defined in:
- lib/pivotal_to_trello/runner.rb
Overview
Utility class to handle the different commands that the ‘pivotal-to-trello’ command offers.
Class Method Summary collapse
-
.execute ⇒ Object
Start running a pivotal-to-trello command from the passed-in arguments.
Instance Method Summary collapse
-
#execute!(options) ⇒ Object
Dispatch central.
-
#import(options) ⇒ Object
Generates a film clip for the given input file, and saves it to the given output path.
-
#parse_options(args) ⇒ Object
Parses the options, and displays help messages if the options given are incorrect.
-
#show_version ⇒ Object
Display the current version of Ruby-Processing.
Class Method Details
.execute ⇒ Object
Start running a pivotal-to-trello command from the passed-in arguments.
9 10 11 12 13 |
# File 'lib/pivotal_to_trello/runner.rb', line 9 def self.execute runner = new = runner.(ARGV) runner.execute!() end |
Instance Method Details
#execute!(options) ⇒ Object
Dispatch central.
16 17 18 19 20 |
# File 'lib/pivotal_to_trello/runner.rb', line 16 def execute!() case .action when :import then import() end end |
#import(options) ⇒ Object
Generates a film clip for the given input file, and saves it to the given output path.
99 100 101 |
# File 'lib/pivotal_to_trello/runner.rb', line 99 def import() PivotalToTrello::Core.new().import! end |
#parse_options(args) ⇒ Object
Parses the options, and displays help messages if the options given are incorrect.
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/pivotal_to_trello/runner.rb', line 24 def (args) = OpenStruct.new commands = { 'import' => OptionParser.new do |opts| opts. = 'Usage: pivotal-to-trello import [options]' opts.separator '' opts.separator 'All arguments except for -v and -h are required.' opts.separator '' opts.separator 'Options:' opts.on('-k', '--trello-key KEY', 'Trello application key') do |trello_key| .trello_key = trello_key end opts.on('-t', '--trello-token TOKEN', 'Trello member token') do |trello_token| .trello_token = trello_token end opts.on('-p', '--pivotal-token TOKEN', 'Pivotal Tracker API token') do |pivotal_token| .pivotal_token = pivotal_token end # Miscellaneous. opts.on_tail('-v', '--version', 'Show version information') { show_version } opts.on_tail('-h', '--help', 'Show this message') do STDOUT.write opts exit end opts.on do if .trello_key && \ .trello_token && \ .pivotal_token .action = :import else # Output a help message unless the required options have been specified. .action = :error STDOUT.write commands['import'] end end end, } global = OptionParser.new do |opts| opts. = "Usage: pivotal-to-trello [#{commands.keys.join(', ')}] [options]" opts.separator '' opts.separator 'pivotal-to-trello is a library for importing stories from Pivotal Tracker into Trello.' opts.separator '' opts.separator "Use pivotal-to-trello [#{commands.keys.join(', ')}] -h to find out more about a specific command" opts.separator '' opts.separator 'Other options:' opts.on_tail('-v', '--version', 'Show version information') do show_version exit end opts.on_tail('-h', '--help', 'Show this message') do STDOUT.write opts exit end end global.order! command = args.shift commands[command].order! if commands[command] # Output a help message unless a command has been specified. STDOUT.write global unless .action end |
#show_version ⇒ Object
Display the current version of Ruby-Processing.
104 105 106 |
# File 'lib/pivotal_to_trello/runner.rb', line 104 def show_version STDOUT.write "pivotal-to-trello version #{PivotalToTrello.version}" end |