Class: EYCli::Command::Help

Inherits:
Base
  • Object
show all
Defined in:
lib/ey_cli/commands/help.rb

Defined Under Namespace

Classes: HelpParser

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#run

Instance Method Details

#helpObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ey_cli/commands/help.rb', line 33

def help
  <<-EOF

Usage: ey_cli command [args]
Try `ey_cli help commands' to list the available commands.
Try `ey_cli help [command]' for more information about a command.

Currently available commands:

  General info
    accounts                     List the accounts associated to a user.
    console                      Start an interactive session to use ey_cli.
    help                         Show commands information.

  Applications
    apps                         List the applications associated to a user.
    create_app                   Create a new application. It takes the information from the current directory.
    show                         Show information and status of an application.

  Environments
    create_env                   Create a new environment for an application.
    deploy                       Run a deploy for an application.
EOF
end

#invokeObject



5
6
7
8
9
10
11
12
# File 'lib/ey_cli/commands/help.rb', line 5

def invoke
  name = options[:command_name] || 'help'
  if name == 'commands'
    print_commands
  else
    print_command_help(name)
  end
end

#options_parserObject



29
30
31
# File 'lib/ey_cli/commands/help.rb', line 29

def options_parser
  HelpParser.new
end


14
15
16
17
18
19
20
21
# File 'lib/ey_cli/commands/help.rb', line 14

def print_command_help(name)
  command = EYCli.command_manager[name]
  if command_help = (command and command.help)
    EYCli.term.say(command_help)
  else
    EYCli.term.say("help not available for command: '#{name}'")
  end
end


23
24
25
26
27
# File 'lib/ey_cli/commands/help.rb', line 23

def print_commands
  EYCli.term.say("available commands:")
  command_names = EYCli.command_manager.commands.keys.map {|name| "- #{name}"}.sort
  EYCli.term.say("\t" + command_names.join("\n\t"))
end