Class: GHI::Commands::Comment
- Defined in:
- lib/ghi/commands/comment.rb
Constant Summary
Constants included from Formatting
Formatting::CURSOR, Formatting::THROBBERS
Constants included from Formatting::Colors
Formatting::Colors::ANSI, Formatting::Colors::WEB
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#web ⇒ Object
Returns the value of attribute web.
Attributes inherited from Command
Attributes included from Formatting
Instance Method Summary collapse
Methods inherited from Command
#api, #assigns, execute, #initialize, #repo, #repo=
Methods included from Formatting
#columns, #dimensions, #format_comment, #format_comment_editor, #format_comments_and_events, #format_date, #format_editor, #format_event, #format_event_type, #format_issue, #format_issues, #format_issues_header, #format_labels, #format_markdown, #format_milestone, #format_milestone_editor, #format_milestones, #format_number, #format_state, #format_tag, #format_username, #indent, #page, #paginate?, #paging?, #past_due?, #percent, #puts, #throb, #truncate
Methods included from Formatting::Colors
#bg, #blink, #bright, #colorize?, colorize?, #fg, #highlight, #inverse, #no_color, #to_hex, #underline
Constructor Details
This class inherits a constructor from GHI::Commands::Command
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
4 5 6 |
# File 'lib/ghi/commands/comment.rb', line 4 def comment @comment end |
#verbose ⇒ Object
Returns the value of attribute verbose.
5 6 7 |
# File 'lib/ghi/commands/comment.rb', line 5 def verbose @verbose end |
#web ⇒ Object
Returns the value of attribute web.
6 7 8 |
# File 'lib/ghi/commands/comment.rb', line 6 def web @web end |
Instance Method Details
#execute ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ghi/commands/comment.rb', line 40 def execute require_issue require_repo self.action ||= 'create' .parse! args case action when 'list' get_requests(:index, :events) res = index page do elements = sort_by_creation(res.body + paged_events(events, res)) puts format_comments_and_events(elements) break unless res.next_page res = throb { api.get res.next_page } end when 'create' if web Web.new(repo).open "issues/#{issue}#issue_comment_form" else create end when 'update', 'destroy' res = index res = throb { api.get res.last_page } if res.last_page self.comment = res.body.reverse.find { |c| c['user']['login'] == Authorization.username } if comment send action else abort 'No recent comment found.' end when 'close' Close.execute [issue, '-m', assigns[:body], '--', repo].compact end end |
#options ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ghi/commands/comment.rb', line 8 def OptionParser.new do |opts| opts. = <<EOF usage: ghi comment [options] <issueno> EOF opts.separator '' opts.on '-l', '--list', 'list comments' do self.action = 'list' end opts.on('-w', '--web') { self.web = true } # opts.on '-v', '--verbose', 'list events, too' opts.separator '' opts.separator 'Comment modification options' opts.on '-m', '--message [<text>]', 'comment body' do |text| assigns[:body] = text end opts.on '--amend', 'amend previous comment' do self.action = 'update' end opts.on '-D', '--delete', 'delete previous comment' do self.action = 'destroy' end opts.on '--close', 'close associated issue' do self.action = 'close' end opts.on '-v', '--verbose' do self.verbose = true end opts.separator '' end end |