Module: Fabric

Defined in:
lib/fabric.rb

Defined Under Namespace

Modules: Test

Constant Summary collapse

@@options =
{}

Class Method Summary collapse

Class Method Details

.narrate_asObject



5
6
7
# File 'lib/fabric.rb', line 5

def self.narrate_as
  'fabric'
end

.options(option = nil) ⇒ Object



10
11
12
13
# File 'lib/fabric.rb', line 10

def self.options(option = nil)
  return @@options[option] if option
  @@options
end

.run!(arguments) ⇒ Object



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
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fabric.rb', line 15

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