Sha256: 6a0d674edc05ddec38da77199f17e84cd9c3416d3f06c18546026a7fab61c9a2
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
module Marvin class CoreCommands < CommandHandler exposes :help desc "Generates this usage statement" def help(methods) method_names = exposed_method_names.map { |n| n.to_s } documented_names = descriptions.keys.map { |k| k.to_s } & method_names if methods.empty? width = documented_names.map { |s| s.length }.max say "Hello there, I know the following commands:" documented_names.each { |name| say "#{name.ljust(width)} - #{descriptions[name.to_sym]}" } say "As well as the following undescribed commands: #{(method_names - documented_names).sort.join(", ")}" else m = methods.first if documented_names.include? m.to_s reply "#{m}: #{descriptions[m.to_sym]}" else reply "I'm sorry, I can't help with #{m} - it seems to be undocumented." end end end exposes :about desc "Displays the current marvin and ruby versions." def about(*args) reply "Marvin v#{Marvin::VERSION::STRING} running on Ruby #{RUBY_VERSION} (#{RUBY_PLATFORM})" end end end
Version data entries
4 entries across 4 versions & 1 rubygems