Class: Travis::CLI::Help

Inherits:
Command show all
Defined in:
lib/travis/cli/help.rb

Defined Under Namespace

Classes: CommandGroup

Constant Summary

Constants inherited from Command

Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK

Constants included from Tools::Assets

Tools::Assets::BASE

Instance Attribute Summary

Attributes inherited from Command

#arguments, #config, #debug, #force_interactive, #formatter, #input, #output

Instance Method Summary collapse

Methods inherited from Command

abstract, abstract?, #check_completion, #check_ruby, #check_version, command_name, #command_name, #debug?, description, #error, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, subcommands, #terminal, #time, #usage, #usage_for, #warn, #write_to

Methods included from Tools::Assets

#asset, #asset_path

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

This class inherits a constructor from Travis::CLI::Command

Instance Method Details

#api_commandsObject



33
34
35
36
37
38
# File 'lib/travis/cli/help.rb', line 33

def api_commands
  CLI.commands.select do |cmd|
    cmd.ancestors.include?(CLI::ApiCommand) &&
    !cmd.ancestors.include?(CLI::RepoCommand)
  end.sort_by {|c| c.command_name}
end

#cmd_group_header(title) ⇒ Object



29
30
31
# File 'lib/travis/cli/help.rb', line 29

def cmd_group_header(title)
  say "    #{color(title, :green)}"
end

#other_commandsObject



46
47
48
49
50
# File 'lib/travis/cli/help.rb', line 46

def other_commands
  CLI.commands.select do |cmd|
    !cmd.ancestors.include? CLI::ApiCommand
  end.sort_by {|c| c.command_name}
end

#repo_commandsObject



40
41
42
43
44
# File 'lib/travis/cli/help.rb', line 40

def repo_commands
  CLI.commands.select do |cmd|
    cmd.ancestors.include? CLI::RepoCommand
  end.sort_by {|c| c.command_name}
end

#run(command = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/travis/cli/help.rb', line 10

def run(command = nil)
  if command
    say CLI.command(command).new.help
  else
    api_cmds   = CommandGroup.new(api_commands,   'API commands')
    repo_cmds  = CommandGroup.new(repo_commands,  'Repo commands')
    other_cmds = CommandGroup.new(other_commands, 'non-API commands')

    say "Usage: travis COMMAND ...\n\nAvailable commands:\n\n"
    [other_cmds, api_cmds, repo_cmds].each do |cmd_grp|
      say "    #{cmd_grp.header}"
      cmd_grp.cmds.each do |cmd|
        say "        #{color(cmd.command_name, :command).ljust(22)} #{color(cmd.description, :info)}"
      end
    end
    say "\nrun `#$0 help COMMAND` for more info"
  end
end