Class: Ki::KiInfoCommand
Overview
Lists available Ki commands
Instance Method Summary collapse
-
#execute(ctx, args) ⇒ Object
Finds all commands under /commands and outputs their id and summary.
- #help ⇒ Object
- #opts ⇒ Object
Instance Method Details
#execute(ctx, args) ⇒ Object
Finds all commands under /commands and outputs their id and summary
197 198 199 |
# File 'lib/cmd/cmd.rb', line 197 def execute(ctx, args) opts.parse(args.empty? ? ["-c"] : args) end |
#help ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/cmd/cmd.rb', line 221 def help <<EOF "#{shell_command}" shows information about Ki. ### Examples #{shell_command} -c #{shell_command} -r ### Parameters #{opts} EOF end |
#opts ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/cmd/cmd.rb', line 201 def opts SimpleOptionParser.new do |opts| opts.on("-c", "--commands", "List commands") do |v| commands = KiCommand::KiExtensions.find(KiCommand::CommandPrefix[0..-2]) commands.each do |id, service_class| puts " #{id[KiCommand::CommandPrefix.size..-1]}: #{service_class.new.summary}" end end opts.on("-r", "--registered", "List all registered extensions") do |v| by_parent = KiCommand::KiExtensions.by_parent by_parent.keys.sort.each do |parent_key| puts "#{parent_key}:" by_parent[parent_key].each do |url, clazz| puts " - #{url[parent_key.size+1..-1]} (#{clazz.name})" end end end end end |