Class: GHI::Commands::Command

Inherits:
Object
  • Object
show all
Includes:
Formatting
Defined in:
lib/ghi/commands/command.rb

Direct Known Subclasses

Assign, Close, Comment, Config, Disable, Edit, Enable, Help, Label, List, Milestone, Open, Show, Status

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

Instance Attribute Summary collapse

Attributes included from Formatting

#paging

Class Method Summary collapse

Instance Method Summary collapse

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_repoObject

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

#actionObject

Returns the value of attribute action.



23
24
25
# File 'lib/ghi/commands/command.rb', line 23

def action
  @action
end

#argsObject (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

Parameters:

  • value

    the value to set the attribute issue to.



22
23
24
# File 'lib/ghi/commands/command.rb', line 22

def issue=(value)
  @issue = value
end

#verboseObject

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

#apiObject



34
35
36
# File 'lib/ghi/commands/command.rb', line 34

def api
  @api ||= Client.new
end

#assignsObject



30
31
32
# File 'lib/ghi/commands/command.rb', line 30

def assigns
  @assigns ||= {}
end

#repoObject 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