Class: Flintlock::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/flintlock/cli.rb

Instance Method Summary collapse

Instance Method Details

#defaults(uri) ⇒ Object



73
74
75
76
77
78
# File 'lib/flintlock/cli.rb', line 73

def defaults(uri)
  mod = get_module(uri)
  mod.defaults.each do |k,v|
    puts "#{k}=#{v}"
  end
end

#deploy(uri, app_dir) ⇒ Object



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
# File 'lib/flintlock/cli.rb', line 13

def deploy(uri, app_dir)
  app_dir = File.expand_path(app_dir)
  say_status "run", "fetching module", :magenta
  mod = get_module(uri, options)
  return if options[:halt] == 'fetch'

  begin
    say_status "run", "detecting compatibility", :magenta
    mod.detect
    return if options[:halt] == 'detect'

    say_status "info", "deploying #{mod.full_name} to '#{app_dir}'", :blue
    say_status "create", "creating deploy directory"
    mod.create_app_dir(app_dir) rescue abort("deploy directory is not empty")
    say_status "run", "installing and configuring dependencies", :magenta
    mod.prepare
    return if options[:halt] == 'prepare'

    say_status "create", "staging application files"
    mod.stage(app_dir)
    return if options[:halt] == 'stage'

    say_status "run", "launching the application", :magenta
    mod.start(app_dir)
    return if options[:halt] == 'start'

    say_status "run", "altering application runtime environment", :magenta
    mod.modify(app_dir)
    return if options[:halt] == 'modify'

    say_status "info", "complete!", :blue
  rescue Errno::EACCES => e
    abort("#{e.message.gsub(/Permission denied/, 'permission denied')}")
  rescue RunFailure
    abort('stage failed!')
  end
end

#new(directory = Dir.pwd) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/flintlock/cli.rb', line 52

def new(directory = Dir.pwd)
  abort("directory isn't empty!") if ! Util.empty_directory?(directory)
  inside(directory) do
    empty_directory "bin"
    inside("bin") do
      Module.script_names.each do |script|
        create_file script
        chmod script, 0755, :verbose => false
      end
    end 
    create_file(Metadata.filename, Metadata.empty)
  end
end

#package(directory = Dir.pwd) ⇒ Object



68
69
70
# File 'lib/flintlock/cli.rb', line 68

def package(directory = Dir.pwd)
  handle_exception { Module.package(directory, options.dup) }
end

#versionObject



81
82
83
# File 'lib/flintlock/cli.rb', line 81

def version
  puts Flintlock::VERSION
end