Class: Appfront::Command::Config

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

Class Method Summary collapse

Class Method Details

.ls(opts) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/appfront/command/config.rb', line 44

def self.ls(opts)
  find_deploy! opts

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

  vars = api.get("/flow/#{@deploy}/envs")

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

.set(vars, opts) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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

  find_deploy! opts

  spinner "Setting ENV vars..." do
    vars.each do |var|
      k, v = var.split '=', 2
      api.post "/flow/#{@deploy}/envs/#{k}", value: v
    end
  end
  puts 
  puts
  Appfront::Command::Config::ls opts
  puts
  puts 'Please use ps:restart command to restart your app when you\'re ready.'
end

.unset(vars, opts) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/appfront/command/config.rb', line 23

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

  find_deploy! opts

  spinner "Unsetting ENV vars..." do
    vars.each do |var|
      k, v = var.split '=', 2
      api.delete "/flow/#{@deploy}/envs/#{k}"
    end
  end  
  puts 
  puts 
  Appfront::Command::Config::ls opts
  puts
  puts 'Please use ps:restart command to restart your app when you\'re ready.'
end