Class: Travis::CLI::Help

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

Instance Attribute Summary

Attributes inherited from Command

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

Instance Method Summary collapse

Methods inherited from Command

abstract, abstract?, #check_ruby, #check_version, command_name, #command_name, #debug, description, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, #terminal, #usage, #write_to

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

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

Instance Method Details

#commandsObject



18
19
20
# File 'lib/travis/cli/help.rb', line 18

def commands
  CLI.commands.sort_by { |c| c.command_name }
end

#run(command = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/travis/cli/help.rb', line 8

def run(command = nil)
  if command
    say CLI.command(command).new.help
  else
    say "Usage: travis COMMAND ...\n\nAvailable commands:\n\n"
    commands.each { |c| say "\t#{color(c.command_name, :command).ljust(20)} #{color(c.description, :info)}" }
    say "\nrun `#$0 help COMMAND` for more infos"
  end
end