Class: Travis::CLI::Help
Defined Under Namespace
Classes: CommandGroup
Constant Summary
Constants inherited from Command
Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK
Constants included from Tools::Assets
Instance Attribute Summary
Attributes inherited from Command
#arguments, #config, #debug, #force_interactive, #formatter, #input, #output
Instance Method Summary collapse
- #api_commands ⇒ Object
- #cmd_group_header(title) ⇒ Object
- #other_commands ⇒ Object
- #repo_commands ⇒ Object
- #run(command = nil) ⇒ Object
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
Methods included from Parser
Constructor Details
This class inherits a constructor from Travis::CLI::Command
Instance Method Details
#api_commands ⇒ Object
35 36 37 38 39 40 |
# File 'lib/travis/cli/help.rb', line 35 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
31 32 33 |
# File 'lib/travis/cli/help.rb', line 31 def cmd_group_header(title) say " #{color(title, :green)}" end |
#other_commands ⇒ Object
48 49 50 51 52 |
# File 'lib/travis/cli/help.rb', line 48 def other_commands CLI.commands.reject do |cmd| cmd.ancestors.include? CLI::ApiCommand end.sort_by { |c| c.command_name } end |
#repo_commands ⇒ Object
42 43 44 45 46 |
# File 'lib/travis/cli/help.rb', line 42 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/travis/cli/help.rb', line 12 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(25)} #{color(cmd.description, :info)}" end end say "\nrun `#{$PROGRAM_NAME} help COMMAND` for more info" end end |