Class: Kontena::Plugin::Shell::HelpCommand
- Defined in:
- lib/kontena/plugin/shell/commands/help.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#cmd ⇒ Object
completions -> (context, tokens, word) { Kontena::Completer.complete(context.to_a + tokens) }.
- #execute ⇒ Object
Methods inherited from Command
command, completions, description, #has_subcommands?, has_subcommands?, help, #initialize, #run, subcommands
Constructor Details
This class inherits a constructor from Kontena::Plugin::Shell::Command
Instance Method Details
#cmd ⇒ Object
completions -> (context, tokens, word) { Kontena::Completer.complete(context.to_a + tokens) }
11 12 13 14 |
# File 'lib/kontena/plugin/shell/commands/help.rb', line 11 def cmd full_line = context + args[1..-1] cmd = Shell.command(full_line.first) || Shell.command('kontena') end |
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kontena/plugin/shell/commands/help.rb', line 16 def execute if cmd.help.respond_to?(:call) help_text = cmd.help.call(context, args[1..-1]) else help_text = cmd.help end puts help_text if cmd.has_subcommands? puts puts Kontena.pastel.green("Subcommands:") cmd.subcommands.each do |name, sc| puts sprintf(' %-29s %s', name, sc.description) end puts end if args.empty? || (args.size == 1 && args.first == 'help') puts puts 'Kontena Shell commands:' Shell.commands.each do |name, cmd| next if cmd == Kontena::Plugin::Shell::KontenaCommand puts sprintf(' %-29s %s', name, cmd.description) end end end |