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. = <<~HELP Usage: kbsecret help <command> For a list of all commands, see: kbsecret help HELP end cli.dreck errors: false do string :command end end end |
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 <<~KBSECRET_HELP Usage: kbsecret <command> <args ...> Available commands: #{Command.all_command_names.join(", ")} For more information about a particular command, try: kbsecret help <command> KBSECRET_HELP end |