Class: RubyYacht::Runner::Help
- Defined in:
- lib/ruby_yacht/runner/help.rb
Overview
This command provides help information about other commands.
Instance Attribute Summary collapse
-
#command ⇒ Object
The command that we are getting help in.
Class Method Summary collapse
-
.command ⇒ Object
The name of the command.
-
.description ⇒ Object
The short description of the command.
Instance Method Summary collapse
-
#option_parser ⇒ Object
This method gets the command-line options for the command.
-
#parse_positional_arguments(arguments) ⇒ Object
This method extracts arguments from the command line.
-
#run ⇒ Object
This method runs the logic for the command.
Methods inherited from Command
#backtick, #default_project, #docker, #docker_machine, #get_machine_info, #log, #project_named, #projects, short_script_name, #system
Instance Attribute Details
#command ⇒ Object
The command that we are getting help in.
13 14 15 |
# File 'lib/ruby_yacht/runner/help.rb', line 13 def command @command end |
Class Method Details
.command ⇒ Object
The name of the command.
5 |
# File 'lib/ruby_yacht/runner/help.rb', line 5 def self.command; 'help'; end |
.description ⇒ Object
The short description of the command.
8 9 10 |
# File 'lib/ruby_yacht/runner/help.rb', line 8 def self.description "Get information on available commands" end |
Instance Method Details
#option_parser ⇒ Object
This method gets the command-line options for the command.
16 17 18 19 20 |
# File 'lib/ruby_yacht/runner/help.rb', line 16 def option_parser OptionParser.new do || . = "Usage: #{Command.short_script_name} help [command]\n\n#{self.class.description}" end end |
#parse_positional_arguments(arguments) ⇒ Object
This method extracts arguments from the command line.
Parameters
- arguments: Array The command line arguments.
27 28 29 |
# File 'lib/ruby_yacht/runner/help.rb', line 27 def parse_positional_arguments(arguments) self.command = arguments.shift end |
#run ⇒ Object
This method runs the logic for the command.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 |