Class: Dokuen::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
13
14
15
# File 'lib/dokuen/cli.rb', line 9

def initialize(*args)
  super(*args)

  if not options[:config].nil?
    @config = Dokuen::Config.new(options[:config])
  end
end

Instance Method Details

#bootObject



100
101
102
103
104
105
106
107
# File 'lib/dokuen/cli.rb', line 100

def boot
  Dir.glob("#{@config.dokuen_dir}/apps/*") do |appdir|
    next if File.basename(appdir)[0] == '.'
    app = Dokuen::Application.new(File.basename(appdir), @config)
    app.clean
    app.scale
  end
end

#buildpacksObject



129
130
131
# File 'lib/dokuen/cli.rb', line 129

def buildpacks
  system("#{@config.bin_path}/mason buildpacks")
end

#configObject



67
68
69
70
71
72
# File 'lib/dokuen/cli.rb', line 67

def config
  app = Dokuen::Application.new(options[:application], @config)
  app.env.each do |key, val|
    puts "#{key}=#{val}"
  end
end

#config_delete(*vars) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/dokuen/cli.rb', line 91

def config_delete(*vars)
  app = Dokuen::Application.new(options[:application], @config)
  vars.each do |var|
    app.delete_env(var)
  end
  app.restart
end

#config_set(*vars) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/dokuen/cli.rb', line 75

def config_set(*vars)
  app = Dokuen::Application.new(options[:application], @config)
  vars.each do |var|
    key, val = var.chomp.split('=', 2)
    app.set_env(key, val)
  end
  app.restart
end

#createObject



43
44
45
46
# File 'lib/dokuen/cli.rb', line 43

def create
  Dokuen::Application.new(options[:application], @config).create
  puts "git remote add dokuen #{@config.git_user}@#{@config.git_server}:apps/#{options[:application]}.git"
end

#deployObject



50
51
52
53
54
55
56
57
# File 'lib/dokuen/cli.rb', line 50

def deploy
  ENV['GIT_DIR'] = nil
  ENV['PATH'] = "#{@config.bin_path}:#{ENV['PATH']}"
  ENV.each do |k,v|
    puts "#{k}=#{v}"
  end
  Dokuen::Application.new(options[:application], @config).deploy(options[:rev])
end

#install_buildpack(url) ⇒ Object



119
120
121
# File 'lib/dokuen/cli.rb', line 119

def install_buildpack(url)
  system("#{@config.bin_path}/mason buildpacks:install #{url}")
end

#remove_buildpack(name) ⇒ Object



124
125
126
# File 'lib/dokuen/cli.rb', line 124

def remove_buildpack(name)
  system("#{@config.bin_path}/mason buildpacks:uninstall #{name}")
end

#restartObject



85
86
87
88
# File 'lib/dokuen/cli.rb', line 85

def restart
  app = Dokuen::Application.new(options[:application], @config)
  app.restart
end

#run_command(*args) ⇒ Object



134
135
136
137
# File 'lib/dokuen/cli.rb', line 134

def run_command(*args)
  app = Dokuen::Application.new(options[:application], @config)
  app.run_command(args)
end

#scale(spec) ⇒ Object



60
61
62
63
64
# File 'lib/dokuen/cli.rb', line 60

def scale(spec)
  app = Dokuen::Application.new(options[:application], @config)
  app.set_env('DOKUEN_SCALE', spec)
  app.scale
end

#setup(dir) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/dokuen/cli.rb', line 27

def setup(dir)

  @current_script = File.expand_path($0)
  @current_bin_path = File.dirname(@current_script)

  Dir.chdir(dir) do
    setup_dirs
    setup_bin
    setup_gitolite
    write_config
    install_boot_script
    puts Dokuen.template('instructions', binding)
  end
end

#shutdownObject



110
111
112
113
114
115
116
# File 'lib/dokuen/cli.rb', line 110

def shutdown
  Dir.glob("#{@config.dokuen_dir}/apps/*") do |appdir|
    next if File.basename(appdir)[0] == '.'
    app = Dokuen::Application.new(File.basename(appdir), @config)
    app.shutdown
  end
end