Sha256: 5fd42f571ca036d4097080add22c8ff087051fa5bec62c1c98f174ff66d72b2d
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
module Kommand module Commands class Help include Command command_summary "Provides help and usage examples" valid_arguments *Commands::commands.map(&:to_arg) validate_arguments false def self.usage puts <<USAGE usage: #{::Kommand.kommand} #{command_name} <command> The available commands are: USAGE Commands::commands.select { |cmd| cmd != self}.each do |cmd| print " %-#{Commands::commands.sort { |a,b| a.command_name.length <=> b.command_name.length }.last.command_name.length + 2}s" % cmd.command_name puts "# #{cmd.command_summary}" end end def run if arguments.empty? usage return end begin cmd = Commands::commands.select { |cmd| cmd.command_name == arguments.first.key.underscore }.first raise if cmd.nil? puts cmd.command_summary puts print " " cmd.usage rescue puts "Invalid Command: #{arguments.first.key.underscore}" usage end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kommand-0.0.4 | lib/kommand/commands/help.rb |
kommand-0.0.3 | lib/kommand/commands/help.rb |
kommand-0.0.2 | lib/kommand/commands/help.rb |
kommand-0.0.1 | lib/kommand/commands/help.rb |