Module: RubyYacht::Runner

Defined in:
lib/ruby_yacht/runner.rb,
lib/ruby_yacht/runner/help.rb,
lib/ruby_yacht/runner/shell.rb,
lib/ruby_yacht/runner/build.rb,
lib/ruby_yacht/runner/runner.rb,
lib/ruby_yacht/runner/command.rb,
lib/ruby_yacht/runner/implode.rb,
lib/ruby_yacht/runner/checkout.rb,
lib/ruby_yacht/runner/services.rb,
lib/ruby_yacht/runner/build_images.rb,
lib/ruby_yacht/runner/update_hosts.rb,
lib/ruby_yacht/runner/run_containers.rb

Overview

This module groups together classes for running commands for managing the docker environment.

Defined Under Namespace

Classes: Build, BuildImages, Checkout, Command, Help, Implode, RunContainers, Services, Shell, UpdateHosts

Class Method Summary collapse

Class Method Details

.argumentsObject

This method gets the arguments for the current command.


8
9
10
# File 'lib/ruby_yacht/runner/runner.rb', line 8

def self.arguments
  ARGV
end

.commandsObject

This method provides the commands that we can run.


3
4
5
# File 'lib/ruby_yacht/runner/runner.rb', line 3

def self.commands
  [Help, Build, BuildImages, RunContainers, Services, Checkout, Shell, UpdateHosts, Implode]
end

.runObject

This method runs a command based on the command line arguments.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby_yacht/runner/runner.rb', line 13

def self.run
  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
  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)
    end
  else
    puts "Command not recognized: #{arg}"
    puts "Run `#{$0} help` for more information"
    exit(1)
  end
end