Class: Brightly::Provider::Exec

Inherits:
Object
  • Object
show all
Defined in:
lib/brightly/provider/exec.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Exec

Returns a new instance of Exec.



8
9
10
11
12
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
42
43
44
45
46
47
48
49
50
# File 'lib/brightly/provider/exec.rb', line 8

def initialize(argv)
  options = {}

  OptionParser.new do |opts|
    opts.banner { "Usage: brightly [options]" }
    # Sinatra params
    opts.on('-x')         {       options[:lock] = true }
    opts.on('-s server')  { |val| options[:server] = val }
    opts.on('-e env')     { |val| options[:environment] = val.to_sym }
    opts.on('-p port')    { |val| options[:port] = val.to_i }
    
    opts.on('-r', '--rack-file', 'Prints the path to the builtin rack file and the contents of the file.') do
      config = rack_file

      puts "#{config}:"
      puts File.read(config)
      exit
    end
    
    opts.on('-p path', '--passenger path', 'Generate an apache passenger config and directory structure.') do |val|
      config = rack_file
      
      FileUtils.mkdir_p(File.join(val))
      FileUtils.mkdir_p(File.join(val, 'tmp'))
      FileUtils.mkdir_p(File.join(val, 'public'))

      FileUtils.cp(config, File.join(val))

      puts "You apache conf should look something like:"
      puts <<-CONF
<VirtualHost *:80>
    ServerName brightly.local
    DocumentRoot #{File.expand_path(File.join(val, 'public'))}
</VirtualHost>
CONF
      exit
    end

    opts.on_tail('-h', '--help', "Show this message") { puts opts ; exit }
  end.parse!

  Brightly::Provider::Base.run! options
end