class Travis::CLI::Help

Constants

CommandGroup

Public Instance Methods

api_commands() click to toggle source
# 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) click to toggle source
# File lib/travis/cli/help.rb, line 29
def cmd_group_header(title)
  say "    #{color(title, :green)}"
end
other_commands() click to toggle source
# 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_commands() click to toggle source
# 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) click to toggle source
# 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