class HelpCommand
woodstove helpcommand - help command for woodstove Copyright © 2016 the furry entertainment project Licensed under the MIT license.
Public Class Methods
new(cmd)
click to toggle source
# File lib/woodstove/helpcommand.rb, line 6 def initialize cmd @cmd = cmd end
Public Instance Methods
cmdify(command)
click to toggle source
Produce a formatted command string for the given command.
# File lib/woodstove/helpcommand.rb, line 16 def cmdify command optprefix = command.opts != '' ? ' ' + command.opts : '' "#{command.long}, #{command.short}#{optprefix}" end
incorrect_usage()
click to toggle source
# File lib/woodstove/helpcommand.rb, line 40 def incorrect_usage usage puts "For more information: `#{@cmd} help`" end
info()
click to toggle source
# File lib/woodstove/helpcommand.rb, line 13 def info; 'Prints help information.'; end
long()
click to toggle source
# File lib/woodstove/helpcommand.rb, line 10 def long; 'help'; end
opts()
click to toggle source
# File lib/woodstove/helpcommand.rb, line 12 def opts; ''; end
run(args)
click to toggle source
# File lib/woodstove/helpcommand.rb, line 20 def run args usage # Get the length of the longest command string, so that we can pad the # information in the output. max_length = 0 $argmanager.commands.each do |command| max_length = [max_length, cmdify(command[1]).length].max end # Print each command's information, with padding after the command string. puts "\nOptions:" $argmanager.commands.each do |command| padded = "%-#{max_length}s" % cmdify(command[1]) puts " #{padded} - #{command[1].info}" end end
short()
click to toggle source
# File lib/woodstove/helpcommand.rb, line 11 def short; 'h'; end
usage()
click to toggle source
# File lib/woodstove/helpcommand.rb, line 37 def usage puts "Usage: #{@cmd} [command] [options]" end