class ConfConf::CLI::Variables

Public Instance Methods

remove(*name_args) click to toggle source
# 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) click to toggle source
# 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