class RubyYacht::Runner::Help
This command provides help information about other commands.
Attributes
command[RW]
The command that we are getting help in.
Public Class Methods
command()
click to toggle source
The name of the command.
# File lib/ruby_yacht/runner/help.rb, line 5 def self.command; 'help'; end
description()
click to toggle source
The short description of the command.
# File lib/ruby_yacht/runner/help.rb, line 8 def self.description "Get information on available commands" end
Public Instance Methods
option_parser()
click to toggle source
This method gets the command-line options for the command.
# File lib/ruby_yacht/runner/help.rb, line 16 def option_parser OptionParser.new do |options| options.banner = "Usage: #{Command.short_script_name} help [command]\n\n#{self.class.description}" end end
parse_positional_arguments(arguments)
click to toggle source
This method extracts arguments from the command line.
### Parameters
-
**arguments: Array** The command line arguments.
# File lib/ruby_yacht/runner/help.rb, line 27 def parse_positional_arguments(arguments) self.command = arguments.shift end
run()
click to toggle source
This method runs the logic for the command.
# File lib/ruby_yacht/runner/help.rb, line 32 def run if self.command RubyYacht::Runner.commands.each do |command| if command.command == self.command log command.new.option_parser.to_s return true end end log "Command not available: #{self.command}" log "Run #{Command.short_script_name} help for more options" return false end log "Available commands: \n\n" RubyYacht::Runner.commands.each do |command| log "#{command.command}: #{command.description}" end log "\nRun #{Command.short_script_name} help [command] for more information on a command" true end