Class: Backlog::Cli::Commands
- Inherits:
-
Thor
- Object
- Thor
- Backlog::Cli::Commands
- Defined in:
- lib/backlog/cli/commands.rb
Instance Method Summary collapse
- #create_issue(project_key) ⇒ Object
- #create_issue_by_file ⇒ Object
- #find_issue(project_key) ⇒ Object
- #get_comments ⇒ Object
- #get_issue ⇒ Object
- #get_project_summaries ⇒ Object
- #get_projects ⇒ Object
- #get_users(project_key) ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Commands
constructor
A new instance of Commands.
- #list(project_key) ⇒ Object
- #open ⇒ Object
- #update_issue ⇒ Object
- #update_issue_by_file ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Commands
Returns a new instance of Commands.
21 22 23 24 25 |
# File 'lib/backlog/cli/commands.rb', line 21 def initialize(args = [], = {}, config = {}) super(args, , config) profile = config[:shell].base.['profile'] @core = Backlog::Cli::Core.new(profile) end |
Instance Method Details
#create_issue(project_key) ⇒ Object
31 32 33 |
# File 'lib/backlog/cli/commands.rb', line 31 def create_issue(project_key) puts JSON.pretty_generate(@core.create_issue(project_key.upcase, )) end |
#create_issue_by_file ⇒ Object
113 114 115 116 117 |
# File 'lib/backlog/cli/commands.rb', line 113 def create_issue_by_file yaml = load_yaml project_key = yaml.delete(:project_key) @core.create_issue(project_key, yaml) end |
#find_issue(project_key) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/backlog/cli/commands.rb', line 68 def find_issue(project_key) results = @core.find_issue(project_key.upcase, ) selected = results.map do |result| result.select { |k, v| %w(id url key summary description).include? k } end puts JSON.pretty_generate(selected.reverse) end |
#get_comments ⇒ Object
37 38 39 |
# File 'lib/backlog/cli/commands.rb', line 37 def get_comments puts JSON.pretty_generate(@core.get_comments()) end |
#get_issue ⇒ Object
50 51 52 53 |
# File 'lib/backlog/cli/commands.rb', line 50 def get_issue result = @core.get_issue() puts JSON.pretty_generate(result) end |
#get_project_summaries ⇒ Object
101 102 103 104 |
# File 'lib/backlog/cli/commands.rb', line 101 def get_project_summaries results = @core.get_project_summaries puts JSON.pretty_generate(results) end |
#get_projects ⇒ Object
95 96 97 98 |
# File 'lib/backlog/cli/commands.rb', line 95 def get_projects results = @core.get_projects puts JSON.pretty_generate(results) end |
#get_users(project_key) ⇒ Object
107 108 109 110 |
# File 'lib/backlog/cli/commands.rb', line 107 def get_users(project_key) results = @core.get_users(project_key.upcase) puts JSON.pretty_generate(results) end |
#list(project_key) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/backlog/cli/commands.rb', line 78 def list(project_key) items = @core.get_rss(project_key.upcase).slice(0, [:limit]) results = [] items.each do |item| result = {} result[:title] = item.title result[:content] = item.content result[:authors] = item..first result[:date_published] = item.date_published result[:url] = item.id result[:urls] = @core.urls(item.content) results << result end puts JSON.pretty_generate(results.reverse) end |
#open ⇒ Object
57 58 59 60 |
# File 'lib/backlog/cli/commands.rb', line 57 def open result = @core.get_issue() `open #{result['url']}` end |
#update_issue ⇒ Object
44 45 46 |
# File 'lib/backlog/cli/commands.rb', line 44 def update_issue puts JSON.pretty_generate(@core.update_issue()) end |
#update_issue_by_file ⇒ Object
120 121 122 |
# File 'lib/backlog/cli/commands.rb', line 120 def update_issue_by_file @core.update_issue(load_yaml) end |
#version ⇒ Object
125 126 127 |
# File 'lib/backlog/cli/commands.rb', line 125 def version puts Backlog::Cli::VERSION end |