lib/toolshed/commands/ticket_information.rb in toolshed-0.0.9 vs lib/toolshed/commands/ticket_information.rb in toolshed-1.0.0

- old
+ new

@@ -3,26 +3,34 @@ class TicketInformation def execute(args, options = {}) begin ticket_tracker_class = Object.const_get("Toolshed::TicketTracking::#{Toolshed::Client.ticket_tracking_tool.camel_case}") - if Object.const_get("#{ticket_tracker_class}::USE_PROJECT_ID") - ticket_tracker_project_id = read_user_input_project_id("Project ID (Default: #{Toolshed::Client.default_pivotal_tracker_project_id}):", options.merge!({ default: Toolshed::Client.default_pivotal_tracker_project_id })) + use_project_id = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_ID") rescue false + if use_project_id + ticket_tracker_project_id = read_user_input_project("Project ID (Default: #{Toolshed::Client.default_pivotal_tracker_project_id}):", options.merge!({ default: Toolshed::Client.default_pivotal_tracker_project_id })) options.merge!({ project_id: ticket_tracker_project_id }) end - ticket_tracker = ticket_tracker_class.create_instance(options) + use_project_name = Object.const_get("#{ticket_tracker_class}::USE_PROJECT_NAME") rescue false + if use_project_name + ticket_tracker_project_name = read_user_input_project("Project Name (Default: #{Toolshed::Client.default_ticket_tracker_project}):", options.merge!({ default: Toolshed::Client.default_ticket_tracker_project })) + options.merge!({ project: ticket_tracker_project_name }) + end - default_ticket_id = Toolshed::TicketTracking::PivotalTracker::story_id_from_branch_name(Toolshed::Git::Base.branch_name) + default_ticket_id = Toolshed::TicketTracking::story_id_from_branch_name(Toolshed::Git::Base.branch_name) ticket_id = read_user_input_ticket_id("Story ID (Default: #{default_ticket_id}):", options.merge!({ default: default_ticket_id })) + options.merge!({ ticket_id: ticket_id }) - if Object.const_get("#{ticket_tracker_class}::USE_PROJECT_ID") + ticket_tracker = ticket_tracker_class.create_instance(options) + + if use_project_id puts "Using Project: #{ticket_tracker_project_id}" end puts "Using Ticket: #{ticket_id}" - result = ticket_tracker.story_information(ticket_id) + result = ticket_tracker.ticket if (options[:field]) field_value = result.send(options[:field]) if (options[:clipboard]) Clipboard.copy field_value @@ -47,10 +55,10 @@ puts e.message exit end end - def read_user_input_project_id(message, options) + def read_user_input_project(message, options) return options[:default] if (options.has_key?(:use_defaults)) puts message value = $stdin.gets.chomp