require 'yaml' require 'highline' require 'tempfile' require 'uri' require 'thor' require 'paint' # String patch monkey class String %i[blue yellow green red white black magenta cyan bold].each do |color| define_method(color) do Paint[self, color] end end end module PT class CLI < Thor include PT::Action include PT::IO attr_reader :project TYPE=%w[feature bug chore release] ACTION = %w[show open start finish deliver accept reject done assign estimate tasks comment add_label edit unstart] default_task :mywork def initialize(*args) super @io = HighLine.new @config = PT::Configuration.new @client = @config.client || Client.new @project = @client.project end %w[unscheduled started finished delivered accepted rejected].each do |state| desc "#{state} ", "show all #{state} stories" define_method(state.to_sym) do |owner = nil| filter = "state:#{state}" filter << " owner:#{owner}" if owner select_story_from_paginated_table(title: "#{state} stories") do |page| @client.get_stories(filter: filter, page: page) end end end ACTION.each do |action| desc "#{action} [id]", "#{action} story" define_method(action.to_sym) do |story_id = nil| if story_id if story = @client.project.story(story_id.to_i) title("#{action} '#{story.name}'") send("#{action}_story", story) else message("No matches found for '#{story_id}', please use a valid pivotal story Id") return end else method_name = "get_stories_to_#{action}" story = select_story_from_paginated_table(default_action: action, title: "Stories to #{action}") do |page| if @client.respond_to?(method_name.to_sym) @client.send("get_stories_to_#{action}", page: page) else @client.get_stories(page: page) end end end end end desc "label