Sha256: 7f25a431daea6e92e1f90e553e8c35653f7f568829715f65ab0901bb2a591f18

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

require "#{File.dirname(__FILE__)}/../lib/divvy"
require 'optparse'
require 'ostruct'

OPTIONS = {}

options = OpenStruct.new
options.verbose = false
options.test = false

parser = OptionParser.new do |opts|
  opts.banner = <<BANNER
Divvy
=====

Divvy is a software provisioning tool you canuse to build remote servers with. 

Usage
=====

$> #{File.basename($0)} [options]

Options are:
BANNER
  opts.separator ""
  
  opts.on("-s", "--script=PATH", "The divvy script to run") do |script|
    options.script = script
  end

  opts.on("-t", "--[no-]test", "Process but do not perform actions") do |t|
    options.test = t
  end
  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
    options.verbose = v
  end

  opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
  opts.parse!(ARGV)
  
  unless options.script
    puts "script is required"
    puts opts
    exit
  end
  
end

Divvy::OPTIONS = options

class Runner
  def self.divvy(script, filename = '__SCRIPT__')
    thingy = new
    thingy.instance_eval script, filename
  end
end

Runner.divvy(File.read(Divvy::OPTIONS.script), Divvy::OPTIONS.script)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mdwan-divvy-0.1.0 bin/divvy
mdwan-divvy-0.1.1 bin/divvy
mdwan-divvy-0.1.2 bin/divvy