Class: Rallycat::CLI
- Inherits:
-
Object
- Object
- Rallycat::CLI
- Defined in:
- lib/rallycat/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv, stdout = STDOUT) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, stdout = STDOUT) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 12 13 |
# File 'lib/rallycat/cli.rb', line 7 def initialize(argv, stdout=STDOUT) @argv = argv @stdout = stdout end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/rallycat/cli.rb', line 5 def @options end |
Instance Method Details
#run ⇒ Object
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 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rallycat/cli.rb', line 15 def run case @command when 'cat' api = Rallycat::Connection.new([:username], [:password]).api story_number = @argv.shift abort 'The "cat" command requires a story or defect number.' unless story_number @stdout.puts Rallycat::Cat.new(api).story(story_number) when 'update' api = Rallycat::Connection.new([:username], [:password]).api task_number = @argv.shift abort 'The "update" command requires a task number.' unless task_number opts = {} opts[:blocked] = true if [:blocked] opts[:state] = "In-Progress" if [:in_progress] opts[:state] = "Completed" if [:completed] opts[:state] = "Defined" if [:defined] opts[:owner] = [:owner] if [:owner] @stdout.puts Rallycat::Update.new(api).task(task_number, opts) when 'list' api = Rallycat::Connection.new([:username], [:password]).api project = [:project] if [:iteration] @stdout.puts Rallycat::List.new(api).stories(project, [:iteration]) else @stdout.puts Rallycat::List.new(api).iterations(project) end when 'help' # `puts` calls `to_s` @stdout.puts Rallycat::Help.new else @stdout.puts "'#{@command}' is not a supported command. See 'rallycat help'." end rescue Rallycat::RallycatError, ArgumentError => e abort e. end |