Class: S7n::S7nCli::HelpCommand
- Defined in:
- lib/s7n/s7ncli/command.rb
Overview
プログラムを終了するコマンドを表現する。
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from Command
#aliases, create_instance, #description, #help, #initialize, #name, #option_parser, split_name_and_argv, #usage
Constructor Details
This class inherits a constructor from S7n::S7nCli::Command
Instance Method Details
#run(argv) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/s7n/s7ncli/command.rb', line 122 def run(argv) if argv.length > 0 command_name = argv.shift command = Command.create_instance(command_name, world) if command command.help else puts(_("Unknown command: %s") % command_name) end else puts(_("Type 'help <command>' for help on a specific command.")) puts("") puts(_("Available commands:")) command_classes = @@command_classes.values.uniq.sort_by { |klass| klass.const_get("NAME") } command_classes.each do |klass| s = " #{klass.const_get("NAME")}" aliases = klass.const_get("ALIASES") if aliases.length > 0 s << " (#{aliases.sort_by { |s| s.length}.first})" end puts(s) end end return true end |