class PT::CLI
Attributes
project[R]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/pt/cli.rb, line 16 def initialize(*args) super @io = HighLine.new @global_config = load_global_config @local_config = load_local_config @client = Client.new(@global_config[:api_number], @local_config) @project = @client.project end
Public Instance Methods
create(title =nil)
click to toggle source
# File lib/pt/cli.rb, line 105 def create(title =nil) owner = options[:owner] type = options[:type] requester_id = @local_config[:user_id] if title name = title owner = owner || @local_config[:user_name] type = task_type_or_nil(owner) || task_type_or_nil(type) || 'feature' else title("Let's create a new task:") name = ask("Name for the new task:") end owner = @client.find_member(owner).person.id if owner.kind_of?(String) unless owner if ask('Do you want to assign it now? (y/n)').downcase == 'y' members = @client.get_members table = PersonsTable.new(members.map(&:person)) owner = select("Please select a member to assign him the task.", table).id else owner = nil end type = ask('Type? (c)hore, (b)ug, anything else for feature)') end type = case type when 'c', 'chore' 'chore' when 'b', 'bug' 'bug' else 'feature' end owner_ids = [owner] # did you do a -m so you can add a description? if options[:m] editor = ENV.fetch('EDITOR') { 'vi' } temp_path = "/tmp/editor-#{ Process.pid }.txt" system "#{ editor } #{ temp_path }" description = File.read(temp_path) end story = @client.create_story( name: name, owner_ids: owner_ids, requested_by_id: requester_id, story_type: type, description: description ) congrats("#{type} for #{owner} open #{story.url}") show_story(story) end
find(query)
click to toggle source
# File lib/pt/cli.rb, line 162 def find(query) stories = @client.get_stories(filter: query, page: options[:page]) print_stories_table(stories) end
list(owner = nil)
click to toggle source
# File lib/pt/cli.rb, line 66 def list(owner = nil) if owner if owner == "all" stories = @client.get_work else stories = @client.get_my_work(owner) end else members = @client.get_members table = MembersTable.new(members) 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(user) end print_stories_table(stories) end
mywork()
click to toggle source
# File lib/pt/cli.rb, line 60 def mywork stories = @client.get_stories(filter: "owner:#{@local_config[:user_name]} -state:accepted", page: options[:page]) print_stories_table(stories) end
recent()
click to toggle source
# File lib/pt/cli.rb, line 84 def recent title("Your recent stories from #{project_to_s}") stories = @project.stories( ids: @local_config[:recent_tasks].join(',') ) MultiUserTasksTable.new(stories).print @global_config end
updates()
click to toggle source
# File lib/pt/cli.rb, line 168 def updates activities = @client.get_activities tasks = @client.get_my_work title("Recent Activity on #{project_to_s}") activities.each do |activity| show_activity(activity, tasks) end end