Class: GHI::Commands::Help

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#api, #assigns, #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

#commandObject

Returns the value of attribute command.



8
9
10
# File 'lib/ghi/commands/help.rb', line 8

def command
  @command
end

Class Method Details

.execute(args, message = nil) ⇒ Object



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

def self.execute args, message = nil
  new(args).execute message
end

Instance Method Details

#allObject



50
51
52
# File 'lib/ghi/commands/help.rb', line 50

def all
  raise 'TODO'
end

#execute(message = nil) ⇒ Object



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
# File 'lib/ghi/commands/help.rb', line 21

def execute message = nil
  self.command = args.shift if args.first !~ /^-/

  if command.nil? && args.empty?
    puts message if message
    puts <<EOF

The most commonly used ghi commands are:
   list        List your issues (or a repository's)
   show        Show an issue's details
   open        Open (or reopen) an issue
   close       Close an issue
   edit        Modify an existing issue
   comment     Leave a comment on an issue
   label       Create, list, modify, or delete labels
   assign      Assign an issue to yourself (or someone else)
   milestone   Manage project milestones
   status      Determine whether or not issues are enabled for this repo
   enable      Enable issues for the current repo
   disable     Disable issues for the current repo

See 'ghi help <command>' for more information on a specific command.
EOF
    exit
  end

  options.parse! args.empty? ? %w(-m) : args
end

#manObject



54
55
56
57
58
# File 'lib/ghi/commands/help.rb', line 54

def man
  GHI.execute [command, '-h']
  # TODO:
  # exec "man #{['ghi', command].compact.join '-'}"
end

#optionsObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/ghi/commands/help.rb', line 10

def options
  OptionParser.new do |opts|
    opts.banner = 'usage: ghi help [--all] [--man|--web] <command>'
    opts.separator ''
    opts.on('-a', '--all', 'print all available commands') { all }
    opts.on('-m', '--man', 'show man page')                { man }
    opts.on('-w', '--web', 'show manual in web browser')   { web }
    opts.separator ''
  end
end

#webObject



60
61
62
# File 'lib/ghi/commands/help.rb', line 60

def web
  raise 'TODO'
end