module RubyYacht::Runner
This module groups together classes for running commands for managing the docker environment.
Public Class Methods
arguments()
click to toggle source
This method gets the arguments for the current command.
# File lib/ruby_yacht/runner/runner.rb, line 29 def self.arguments ARGV end
clear_commands()
click to toggle source
This method clears our list of commands that we can run.
# File lib/ruby_yacht/runner/runner.rb, line 8 def self.clear_commands @commands = [] end
commands()
click to toggle source
This method provides the commands that we can run.
# File lib/ruby_yacht/runner/runner.rb, line 3 def self.commands @commands ||= [] end
load_default_commands(in_project=true)
click to toggle source
This method loads the default commands into our command list.
### Parameters
-
*in_project Boolean** Whether we are running a script in the context
of a project, or in the top-level ruby_yacht command.
# File lib/ruby_yacht/runner/runner.rb, line 19 def self.load_default_commands(in_project=true) @commands ||= [] if in_project @commands += [Help, Build, BuildImages, RunContainers, Services, Checkout, Shell, UpdateHosts, Implode] else @commands += [Help, CreateNewProject] end end
run()
click to toggle source
This method runs a command based on the command line arguments.
# File lib/ruby_yacht/runner/runner.rb, line 34 def self.run load_default_commands if self.commands == [] arg = arguments[0] if arg == '' || arg == nil puts "You must provide a command to run" puts "Run `#{$0} help` for more information" exit(1) return false end command = self.commands.find { |c| c.command == arg } if command command_arguments = arguments command_arguments.shift instance = command.new instance.option_parser.parse! command_arguments instance.parse_positional_arguments command_arguments success = instance.run unless success exit(1) return false end else puts "Command not recognized: #{arg}" puts "Run `#{$0} help` for more information" exit(1) return false end true end