class Leg::Commands::Help

Public Class Methods

name() click to toggle source
# File lib/leg/commands/help.rb, line 4
def self.name
  "help"
end
summary() click to toggle source
# File lib/leg/commands/help.rb, line 8
def self.summary
  "Print out list of commands, or get help\n" +
  "on a specific command."
end
usage() click to toggle source
# File lib/leg/commands/help.rb, line 13
def self.usage
  "[<command>]"
end

Public Instance Methods

run() click to toggle source
# File lib/leg/commands/help.rb, line 20
def run
  if @args.empty?
    puts "<< Hello! I am leg, version #{Leg::VERSION} >>"
    puts
    puts "Usage: leg <command> [args...]"
    puts
    puts "Commands:"
    Leg::Commands::LIST.each do |cmd|
      puts "  #{cmd.name} #{cmd.usage}"
      cmd.summary.split("\n").each do |line|
        puts "      #{line}"
      end
    end
    puts
    puts "For more help on a specific command, run `leg help <command>`."
  elsif cmd = Leg::Commands::LIST.find { |cmd| cmd.name == @args.first }
    cmd.new(["--help"], @config)
  else
    puts "There is no '#{@args.first}' command."
  end
end
setopts!(o) click to toggle source
# File lib/leg/commands/help.rb, line 17
def setopts!(o)
end