Sha256: 5d2252e49ac39af926ca630c531ed5d7f296cbb72b2e93af34726f7357b57463

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

require 'optparse'
require 'initialisers/data_mapper'

module Fabric
  def self.narrate_as
    'fabric'
  end

  @@options = {}  
  def self.options(option = nil)
    return @@options[option] if option
    @@options
  end
    
  def self.run!(arguments)
    OptionParser.new do |options|
      options.banner = "Usage: fab mapfile [options]"
      
      @@options[:narrate] = false
      options.on('-n', '--narrate', 'Give full narrative output') do
        @@options[:narrate] = true
      end
      
      options.on('-h', '--help', 'Show this help screen') do 
        puts options
        exit
      end
    end.parse!
    
    map_file = arguments.first

    if map_file.nil? or not File.exists?(map_file)
      no_map_error = <<NO_MAP_FILE
      
  Usage: fab mapfile [options]
      
  Please specify a valid map file.
  
NO_MAP_FILE
      
      puts no_map_error
      
      exit 1
    end

    @@options[:map_root] = File.dirname(File.expand_path(map_file))
    narrate "Setting map_root to #{Fabric.options(:map_root)}"

    require map_file
    
    0
  end
end

Dir[File.dirname(__FILE__) + "/**/*.rb"].each do |file|
  require file
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fabric-0.4.4 lib/fabric.rb
fabric-0.4.3 lib/fabric.rb
fabric-0.4.2 lib/fabric.rb
fabric-0.4.1 lib/fabric.rb
fabric-0.4.0 lib/fabric.rb
fabric-0.3.6 lib/fabric.rb
fabric-0.3.5 lib/fabric.rb
fabric-0.3.4 lib/fabric.rb
fabric-0.3.3 lib/fabric.rb
fabric-0.3.2 lib/fabric.rb
fabric-0.3.1 lib/fabric.rb
fabric-0.3.0 lib/fabric.rb
fabric-0.2.0 lib/fabric.rb