Module: Dawn::CLI::Env

Extended by:
BaseCommands
Defined in:
lib/dawn/cli/commands/env.rb

Class Method Summary collapse

Methods included from BaseCommands

command, handle_abort_exception

Methods included from Helpers

#current_app, #current_app_name, #extract_app_in_dir, #extract_app_remote_from_git_config, #git, #git_add_dawn_remote, #git_dawn_remote?, #git_remotes, #git_remove_dawn_remote, #has_git?, #try_create_app

Methods included from OutputFormatter

#format_apps, #format_domains, #format_drains, #format_gears, #format_keys, #format_releases, #table_style

Class Method Details

.get(*keys) ⇒ Object

“Get an ENV var”



20
21
22
23
24
25
# File 'lib/dawn/cli/commands/env.rb', line 20

def self.get(*keys)
  env = current_app.env
  keys.each do |k|
    say "#{k}=#{env[k]}"
  end
end

.listObject

“Displays all the current app’s ENV variables”



11
12
13
14
15
# File 'lib/dawn/cli/commands/env.rb', line 11

def self.list
  current_app.env.each do |k, v|
    say "#{k}=#{v}"
  end
end

.set(env) ⇒ Object

“Set multiple ENV variables”

Parameters:

  • env (Hash<String, String>)


31
32
33
34
35
36
37
# File 'lib/dawn/cli/commands/env.rb', line 31

def self.set(env)
  appenv = current_app.env
  appenv.update(appenv.merge(env)) # this is a Hash method
  appenv.save                       # this is an API method
rescue Excon::Errors::BadRequest => ex
  handle_abort_exception("dawn env set", ex)
end

.unset(*keys) ⇒ Object

“Deletes an ENV var”

Parameters:

  • *keys (Array<String>)


43
44
45
46
47
48
49
50
51
# File 'lib/dawn/cli/commands/env.rb', line 43

def self.unset(*keys)
  env = current_app.env
  keys.each do |k|
    env.delete(k)
  end
  env.save
rescue Excon::Errors::BadRequest => ex
  handle_abort_exception("dawn env unset", ex)
end