Class: GHI::Commands::Command
- Inherits:
-
Object
- Object
- GHI::Commands::Command
- Includes:
- Formatting
- Defined in:
- lib/ghi/commands/command.rb
Direct Known Subclasses
Assign, Close, Comment, Config, Edit, Help, Label, List, Milestone, Open, Show
Constant Summary
Constants included from Formatting
Formatting::CURSOR, Formatting::THROBBERS
Constants included from Formatting::Colors
Formatting::Colors::ANSI, Formatting::Colors::WEB
Class Attribute Summary collapse
-
.detected_repo ⇒ Object
Returns the value of attribute detected_repo.
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#issue ⇒ Object
writeonly
Sets the attribute issue.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Attributes included from Formatting
Class Method Summary collapse
Instance Method Summary collapse
- #api ⇒ Object
- #assigns ⇒ Object
-
#initialize(args) ⇒ Command
constructor
A new instance of Command.
- #repo ⇒ Object (also: #extract_repo)
- #repo=(repo) ⇒ Object
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
#initialize(args) ⇒ Command
Returns a new instance of Command.
26 27 28 |
# File 'lib/ghi/commands/command.rb', line 26 def initialize args @args = args.map! { |a| a.dup } end |
Class Attribute Details
.detected_repo ⇒ Object
Returns the value of attribute detected_repo.
10 11 12 |
# File 'lib/ghi/commands/command.rb', line 10 def detected_repo @detected_repo end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
23 24 25 |
# File 'lib/ghi/commands/command.rb', line 23 def action @action end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
21 22 23 |
# File 'lib/ghi/commands/command.rb', line 21 def args @args end |
#issue=(value) ⇒ Object
Sets the attribute issue
22 23 24 |
# File 'lib/ghi/commands/command.rb', line 22 def issue=(value) @issue = value end |
#verbose ⇒ Object
Returns the value of attribute verbose.
24 25 26 |
# File 'lib/ghi/commands/command.rb', line 24 def verbose @verbose end |
Class Method Details
.execute(args) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ghi/commands/command.rb', line 12 def execute args command = new args if i = args.index('--') command.repo = args.slice!(i, args.length)[1] # Raise if too many? end command.execute end |
Instance Method Details
#api ⇒ Object
34 35 36 |
# File 'lib/ghi/commands/command.rb', line 34 def api @api ||= Client.new end |
#assigns ⇒ Object
30 31 32 |
# File 'lib/ghi/commands/command.rb', line 30 def assigns @assigns ||= {} end |
#repo ⇒ Object Also known as: extract_repo
38 39 40 41 42 43 44 45 |
# File 'lib/ghi/commands/command.rb', line 38 def repo return @repo if defined? @repo @repo = GHI.config('ghi.repo', :flags => '--local') || detect_repo if @repo && !@repo.include?('/') @repo = [Authorization.username, @repo].join '/' end @repo end |
#repo=(repo) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/ghi/commands/command.rb', line 48 def repo= repo @repo = repo.dup unless @repo.include? '/' @repo.insert 0, "#{Authorization.username}/" end @repo end |