lib/pivotal-github/command.rb in pivotal-github-0.8.1 vs lib/pivotal-github/command.rb in pivotal-github-0.9.0

- old
+ new

@@ -12,11 +12,11 @@ end def parse self.known_options = Options::known_options(parser, args) self.unknown_options = Options::unknown_options(parser, args) - parser.parse(known_options) + parser.parse!(known_options) end def parser OptionParser.new end @@ -38,10 +38,30 @@ # Returns the single story id for the common case of one id. def story_id story_ids.first end + # Returns the message for the story id(s) and action (if any). + def message + if finish? + label = "Finishes #{message_ids}" + elsif deliver? + label = "Delivers #{message_ids}" + else + label = message_ids + end + "[#{label}]" + end + + # Returns the story ids formatted for story commits. + # For single-id stories, this is just the number preceded by '#', as in + # '#62831853'. For multiple-id stories, each story id is precede by '#', as in + # '#62831853 #31415926' + def message_ids + story_ids.map { |id| "##{id}" }.join(' ') + end + # Runs a command. # If the argument array contains '--debug', returns the command that would # have been run. def self.run!(command_class, args) debug = args.delete('--debug') @@ -74,7 +94,15 @@ if `which git-pull-request`.empty? msg = "Install git-utils (https://github.com/mhartl/git-utils)" $stderr.puts msg exit 1 end + end + + def finish? + options.finish + end + + def deliver? + options.deliver end end \ No newline at end of file