Class: ConfConf::CLI::Variables

Inherits:
Thor
  • Object
show all
Defined in:
lib/conf_conf/cli/variables.rb

Instance Method Summary collapse

Instance Method Details

#remove(*name_args) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/conf_conf/cli/variables.rb', line 64

def remove(*name_args)
  project      = ConfConf::Project.new

  all_environments = project.environments.to_a

  if options[:env]
    environments = [project.environments[options[:env]]]
  else
    environments = all_environments
  end

  return if environments.length == 0

  name_args.each do |name|
    environments.each do |environment|
      environment.remove(name)
    end
  end

  environments.map(&:save)
end

#set(*env_variable_args) ⇒ Object



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/conf_conf/cli/variables.rb', line 25

def set(*env_variable_args)
  project      = ConfConf::Project.new
  developers   = project.developers

  developer = ConfConf::Project::Developer.current
  developers.add(developer)

  if options[:env]
    environments = [project.environments[options[:env]]]
  else
    environments = project.environments.to_a
  end

  return if environments.length == 0

  env_variable_args.each do |env_variable|
    config_key, config_value = env_variable.split("=").map(&:strip)

    environments.each do |environment|
      environment.set(config_key, config_value)
    end
  end

  environments.map(&:save)
end