Class: PivotalShell::Commands::Start
- Inherits:
-
PivotalShell::Command
- Object
- PivotalShell::Command
- PivotalShell::Commands::Start
- Defined in:
- lib/pivotal_shell/commands/start.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ Start
constructor
A new instance of Start.
Constructor Details
#initialize(options) ⇒ Start
Returns a new instance of Start.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pivotal_shell/commands/start.rb', line 6 def initialize() opts = OptionParser.new do |opts| opts. = "Start a Pivotal story. The story must not be started yet.\nUsage: pivotal start STORY_ID [options]\n\n" opts.on_tail('--help', 'Show this help') do puts opts exit end end opts.parse!() if .empty? || .length>1 puts opts exit else @story_id = .first end end |
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pivotal_shell/commands/start.rb', line 24 def execute @story = PivotalShell::Configuration.project.stories.find(@story_id) if @story.nil? puts 'Story not found' elsif @story.current_state=='started' puts 'Story is already started: '+@story.name elsif ['finished', 'delivered', 'accepted', 'rejected'].include? @story.current_state puts 'Story is already finished: '+@story.name else @story.update(:current_state => 'started') PivotalShell::Configuration.cache.refresh end end |