lib/pt/ui.rb in pt-0.5.4 vs lib/pt/ui.rb in pt-0.5.5

- old
+ new

@@ -40,11 +40,11 @@ PT::TasksTable.new(stories).print end else members = @client.get_members(@project) table = PT::MembersTable.new(members) - user = select("Please select a member to see his tasks", table).name + user = select("Please select a member to see his tasks.", table).name title("Work for #{user} in #{project_to_s}") stories = @client.get_my_work(@project, user) PT::TasksTable.new(stories).print end end @@ -62,11 +62,11 @@ unless owner if ask('Do you want to assign it now? (y/n)').downcase == 'y' members = @client.get_members(@project) table = PT::MembersTable.new(members) - owner = select("Please select a member to assign him the task", table).name + owner = select("Please select a member to assign him the task.", table).name else owner = nil end requester = @local_config[:user_name] task_type = ask('Type? (c)hore, (b)ug, anything else for feature)') @@ -78,15 +78,15 @@ when 'b', 'bug' 'bug' else 'feature' end - result = @client.create_task(@project, name, owner.name, requester, task_type) + result = @client.create_task(@project, name, owner, requester, task_type) if result.errors.any? error(result.errors.errors) else - congrats("#{task_type} for #{owner.name} created, cool.") + congrats("#{task_type} for #{owner} created: #{result.url}") end end def open if @params[0] @@ -265,11 +265,11 @@ end if @params[1] comment = @params[1] else - comment = ask("Please explain why are you rejecting the task") + comment = ask("Please explain why are you rejecting the task.") end if @client.comment_task(@project, task, comment) result = @client.mark_task_as(@project, task, 'rejected') congrats("Task rejected, thanks!") @@ -381,48 +381,48 @@ end end def help - if ARGV[0] + if ARGV[0] && ARGV[0] != 'help' message("Command #{ARGV[0]} not recognized. Showing help.") end title("Command line usage") - message("pt # show all available tasks") - message("pt todo # show all unscheduled tasks") - message("pt create [title] ~[owner] ~[type] # create a new task") - message("pt show [id] # shows detailed info about a task") - message("pt open [id] # open a task in the browser") - message("pt assign [id] [member] # assign owner") - message("pt comment [id] [comment] # add a comment") - message("pt estimate [id] [0-3] # estimate a task in points scale") - message("pt start [id] # mark a task as started") - message("pt finish [id] # indicate you've finished a task") - message("pt deliver [id] # indicate the task is delivered"); - message("pt accept [id] # mark a task as accepted") - message("pt reject [id] [reason] # mark a task as rejected, explaining why") - message("pt find [query] # looks in your tasks by title and presents it") - message("pt done [id] ~[0-3] ~[comment] # lazy mans finish task, does everything") - message("pt list [member] # list all tasks for another pt user") - message("pt updates [number] # shows number recent activity from your current project") - message("") - message("All commands can be ran without arguments for a wizard like UI.") + puts("pt # show all available tasks") + puts("pt todo # show all unscheduled tasks") + puts("pt create [title] ~[owner] ~[type] # create a new task") + puts("pt show [id] # shows detailed info about a task") + puts("pt open [id] # open a task in the browser") + puts("pt assign [id] [member] # assign owner") + puts("pt comment [id] [comment] # add a comment") + puts("pt estimate [id] [0-3] # estimate a task in points scale") + puts("pt start [id] # mark a task as started") + puts("pt finish [id] # indicate you've finished a task") + puts("pt deliver [id] # indicate the task is delivered"); + puts("pt accept [id] # mark a task as accepted") + puts("pt reject [id] [reason] # mark a task as rejected, explaining why") + puts("pt find [query] # looks in your tasks by title and presents it") + puts("pt done [id] ~[0-3] ~[comment] # lazy mans finish task, does everything") + puts("pt list [member] # list all tasks for another pt user") + puts("pt updates [number] # shows number recent activity from your current project") + puts("") + puts("All commands can be ran without arguments for a wizard like UI.") end protected def commands - (public_methods - Object.public_methods).sort.map{ |c| c.to_sym} + (public_methods - Object.public_methods + [:help]).sort.map{ |c| c.to_sym} end # Config def load_global_config config = YAML.load(File.read(GLOBAL_CONFIG_PATH)) rescue {} if config.empty? - message "I can't find info about your Pivotal Tracker account in #{GLOBAL_CONFIG_PATH}" + message "I can't find info about your Pivotal Tracker account in #{GLOBAL_CONFIG_PATH}." while !config[:api_number] do config[:email] = ask "What is your email?" password = ask_secret "And your password? (won't be displayed on screen)" begin config[:api_number] = PT::Client.get_api_token(config[:email], password) @@ -430,11 +430,11 @@ error e.message + " Please try again." end end congrats "Thanks!", "Your API id is " + config[:api_number], - "I'm saving it in #{GLOBAL_CONFIG_PATH} to don't ask you again." + "I'm saving it in #{GLOBAL_CONFIG_PATH} so you don't have to log in again." save_config(config, GLOBAL_CONFIG_PATH) end config end @@ -569,13 +569,14 @@ def show_task(task) title task.name estimation = [-1, nil].include?(task.estimate) ? "Unestimated" : "#{task.estimate} points" message "#{task.current_state.capitalize} #{task.story_type} | #{estimation} | Req: #{task.requested_by} | Owns: #{task.owned_by} | Id: #{task.id}" - message task.description unless task.description.empty? + message task.description unless task.description.nil? || task.description.empty? task.tasks.all.each{ |t| message "- #{t.complete ? "(done) " : "(pend)"} #{t.description}" } task.notes.all.each{ |n| message "#{n.author}: \"#{n.text}\"" } - task.attachments.each{ |a| message "#{a.uploaded_by} uploaded: \"#{a.description.empty? ? "#{a.filename}" : "#{a.description} (#{a.filename})" }\" #{a.url}" } + task.attachments.each{ |a| message "#{a.uploaded_by} uploaded: \"#{a.description && a.description.empty? ? "#{a.filename}" : "#{a.description} (#{a.filename})" }\" #{a.url}" } + puts task.url end def show_activity(activity, tasks) story_id = activity.stories.first.id task_id = nil