Class: GHI::Commands::Label
- Defined in:
- lib/ghi/commands/label.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
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from Command
Attributes included from Formatting
Instance Method Summary collapse
- #execute ⇒ Object
- #issue ⇒ Object
-
#options ⇒ Object
– FIXME: This does too much.
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
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ghi/commands/label.rb', line 4 def name @name end |
Instance Method Details
#execute ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ghi/commands/label.rb', line 56 def execute extract_issue require_repo .parse! args.empty? ? %w(-l) : args if issues_present? self.action ||= 'add' self.name = args.shift.to_s.split ',' self.name.concat args multi_action(action) else self.action ||= 'create' self.name ||= args.shift send action end end |
#issue ⇒ Object
190 191 192 |
# File 'lib/ghi/commands/label.rb', line 190 def issue Thread.current[:issue] end |
#options ⇒ Object
– FIXME: This does too much. Opt for a secondary command, e.g.,
ghi label add <labelname>
ghi label rm <labelname>
ghi label <issueno> <labelname>...
++
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ghi/commands/label.rb', line 13 def OptionParser.new do |opts| opts. = <<EOF usage: ghi label <labelname> [-c <color>] [-r <newname>] or: ghi label -D <labelname> or: ghi label <issueno(s)> [-a] [-d] [-f] <label> or: ghi label -l [<issueno>] EOF opts.separator '' opts.on '-l', '--list [<issueno>]', 'list label names' do |n| self.action = 'index' @issue ||= n end opts.on '-D', '--delete', 'delete label' do self.action = 'destroy' end opts.separator '' opts.separator 'Label modification options' opts.on( '-c', '--color <color>', 'color name or 6-character hex code' ) do |color| assigns[:color] = to_hex color self.action ||= 'create' end opts.on '-r', '--rename <labelname>', 'new label name' do |name| assigns[:name] = name self.action = 'update' end opts.separator '' opts.separator 'Issue modification options' opts.on '-a', '--add', 'add labels to issue' do self.action = issues_present? ? 'add' : 'create' end opts.on '-d', '--delete', 'remove labels from issue' do self.action = issues_present? ? 'remove' : 'destroy' end opts.on '-f', '--force', 'replace existing labels' do self.action = issues_present? ? 'replace' : 'update' end opts.separator '' end end |