Class: GHI::Commands::Close

Inherits:
Command
  • Object
show all
Defined in:
lib/ghi/commands/close.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

Attributes inherited from Command

#action, #args, #verbose

Attributes included from Formatting

#paging

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

#webObject

Returns the value of attribute web.



4
5
6
# File 'lib/ghi/commands/close.rb', line 4

def web
  @web
end

Instance Method Details

#executeObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ghi/commands/close.rb', line 25

def execute
  options.parse! args
  require_repo

  if list?
    args.unshift(*%W(-sc -- #{repo}))
    args.unshift '-w' if web
    List.execute args
  else
    require_issue
    if assigns.key? :comment
      Comment.execute [
        issue, '-m', assigns[:comment], '--', repo
      ].compact
    end
    Edit.execute %W(-sc #{issue} -- #{repo})
  end
end

#optionsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ghi/commands/close.rb', line 6

def options
  OptionParser.new do |opts|
    opts.banner = <<EOF
usage: ghi close [options] <issueno>
EOF
    opts.separator ''
    opts.on '-l', '--list', 'list closed issues' do
      assigns[:command] = List
    end
    opts.on('-w', '--web') { self.web = true }
    opts.separator ''
    opts.separator 'Issue modification options'
    opts.on '-m', '--message [<text>]', 'close with message' do |text|
      assigns[:comment] = text
    end
    opts.separator ''
  end
end