class RHC::Commands::Env

Public Instance Methods

list(app) click to toggle source
# File lib/rhc/commands/env.rb, line 113
def list(app)
  rest_app = find_app
  rest_env_vars = rest_app.environment_variables

  pager

  display_env_var_list(rest_env_vars, { :table => options.table, :quotes => options.quotes })

  0
end
set(env) click to toggle source
# File lib/rhc/commands/env.rb, line 45
def set(env)
  rest_app = find_app

  with_file = env.index {|item| File.file? item}

  env_vars = []
  env.each {|item| env_vars.concat(collect_env_vars(item))}
  raise RHC::EnvironmentVariableNotProvidedException.new(
    (with_file ?
      "Environment variable(s) not found in the provided file(s).\n" :
      "Environment variable(s) not provided.\n") <<
      "Please provide at least one environment variable using the syntax VARIABLE=VALUE. VARIABLE can only contain letters, digits and underscore ('_') and can't begin with a digit.") if env_vars.empty?

  if with_file
    env_vars.each {|item| default_display_env_var(item.name, item.value)}
    confirm_action "Do you want to set these environment variables on '#{rest_app.name}?"
  end

  say 'Setting environment variable(s) ... '
  rest_app.set_environment_variables(env_vars)
  success 'done'

  0
end
show(env) click to toggle source
# File lib/rhc/commands/env.rb, line 130
def show(env)
  rest_app = find_app
  rest_env_vars = rest_app.find_environment_variables(env)

  pager

  display_env_var_list(rest_env_vars, { :table => options.table, :quotes => options.quotes })

  0
end
unset(env) click to toggle source
# File lib/rhc/commands/env.rb, line 84
def unset(env)
  rest_app = find_app

  warn 'Removing environment variables is a destructive operation that may result in loss of data.'

  env.each do |e|
    default_display_env_var(e)
  end

  confirm_action "Are you sure you wish to remove the environment variable(s) above from application '#{rest_app.name}'?"
  say 'Removing environment variable(s) ... '
  rest_app.unset_environment_variables(env)
  success 'done'

  0
end