Class: KBSecret::CLI::Command::Help

Inherits:
Abstract
  • Object
show all
Defined in:
lib/kbsecret/cli/command/help.rb

Overview

The implementation of kbsecret help.

Instance Attribute Summary

Attributes inherited from Abstract

#cli

Instance Method Summary collapse

Methods inherited from Abstract

command_name, config, #setup!, #validate!

Constructor Details

#initialize(argv) ⇒ Help

Returns a new instance of Help.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kbsecret/cli/command/help.rb', line 8

def initialize(argv)
  super(argv) do |cli|
    cli.slop do |o|
      o.banner = "        Usage:\n          kbsecret help <command>\n\n        For a list of all commands, see:\n          kbsecret help\n      HELP\n    end\n\n    cli.dreck errors: false do\n      string :command\n    end\n  end\nend\n"

Instance Method Details

#run!Object

See Also:



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/kbsecret/cli/command/help.rb', line 41

def run!
  command = cli.args[:command]

  if command.empty?
    puts toplevel_help
  elsif Command.internal?(command)
    Command.run! command, "--help"
  elsif Command.external?(command)
    cli.die "Help is not available for external commands."
  else
    cli.die "Unknown command: #{command}."
  end
end

#toplevel_helpString

Returns the top-level "help" string for kbsecret.

Returns:

  • (String)

    the top-level "help" string for kbsecret



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kbsecret/cli/command/help.rb', line 27

def toplevel_help
  "    Usage:\n      kbsecret <command> <args ...>\n\n    Available commands:\n      \#{Command.all_command_names.join(\", \")}\n\n    For more information about a particular command, try:\n      kbsecret help <command>\n  KBSECRET_HELP\nend\n"