Class: Appfront::Command::Config

Inherits:
Base
  • Object
show all
Defined in:
lib/appfront/command/config.rb

Class Method Summary collapse

Class Method Details

.get(args, opts) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/appfront/command/config.rb', line 38

def self.get(args, opts)
  var = args.shift
  find_app! opts

  vars = api.get("/domains/#{@app}")['vars']

  value = vars.select {|v| v['key_name'] == var }.first['value'] rescue nil

  puts value if value
end

.list(opts) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/appfront/command/config.rb', line 49

def self.list(opts)
  find_app! opts

  puts "=== #{@app} Config Vars"

  vars = api.get("/domains/#{@app}")['vars']

  vars.each {|v| puts "#{v['key_name']}:\t#{v['value']}" }
end

.set(vars, opts) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/appfront/command/config.rb', line 2

def self.set(vars, opts)
  unless vars.size > 0 and vars.all? { |a| a.include?('=') }
    puts "Usage: appfront config:set KEY1=VALUE1 [KEY2=VALUE2 ...]\nMust specify KEY and VALUE to set."
    exit 1
  end

  vars = parse_vars! vars

  find_app! opts

  puts "Setting ENV vars..."

  api.post "/apps/#{@app}/vars", vars: vars

  vars.each { |k, v| puts "#{k}:\t#{v}" }

  puts
  puts 'Please use ps:restart command to restart your app when you\'re ready.'
end

.unset(vars, opts) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/appfront/command/config.rb', line 22

def self.unset(vars, opts)
  if vars.empty?
    puts "Usage: appfront config:unset KEY1 [KEY2 ...]\nMust specify KEY to unset."
    exit 1
  end

  find_app! opts

  puts "Unsetting ENV vars..."

  api.post "/apps/#{@app}/vars/unset", vars: vars

  puts
  puts 'Please use ps:restart command to restart your app when you\'re ready.'
end