Class: KBSecret::CLI::Command::Help
- Defined in:
- lib/kbsecret/cli/command/help.rb
Overview
The implementation of kbsecret help
.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(argv) ⇒ Help
constructor
A new instance of Help.
- #run! ⇒ Object
-
#toplevel_help ⇒ String
The top-level "help" string for
kbsecret
.
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. = " 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
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_help ⇒ String
Returns 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" |