Class: Travis::CLI::Env
Constant Summary
Constants inherited
from RepoCommand
RepoCommand::GIT_REGEX, RepoCommand::TRAVIS
Constants inherited
from Command
Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK
Tools::Assets::BASE
Instance Attribute Summary
Attributes inherited from RepoCommand
#slug
Attributes inherited from ApiCommand
#enterprise_name, #session
Attributes inherited from Command
#arguments, #config, #debug, #force_interactive, #formatter, #input, #output
Instance Method Summary
collapse
Methods inherited from RepoCommand
#repository
Methods inherited from ApiCommand
#authenticate, #detected_endpoint?, #endpoint_config, #enterprise?, #initialize, #org?, #pro?, #sync
#access_token, #access_token=, #account, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #hooks, #job, #lint, #listen, #repo, #repos, #restart, #user
Methods inherited from Command
abstract, abstract?, #check_completion, #check_ruby, #check_version, command_name, #command_name, #debug?, description, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, skip, subcommands, #terminal, #time, #usage, #usage_for, #write_to
#asset, #asset_path
Methods included from Parser
#new, #on, #on_initialize
Instance Method Details
#clear ⇒ Object
42
43
44
45
46
|
# File 'lib/travis/cli/env.rb', line 42
def clear
exit if env_vars.empty?
exit 1 if interactive? and not force? and not danger_zone? "Clear out all env variables for #{color(repository.slug, :bold)}?"
remove_vars
end
|
#copy(*names) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/travis/cli/env.rb', line 28
def copy(*names)
names.each do |name|
if ENV.include? name
set(name, ENV[name])
else
warn "missing in current environment: #{color "$#{name}", :bold}"
end
end
end
|
#env_vars ⇒ Object
61
62
63
|
# File 'lib/travis/cli/env.rb', line 61
def env_vars
repository.env_vars
end
|
#list ⇒ Object
56
57
58
59
|
# File 'lib/travis/cli/env.rb', line 56
def list
say color("# environment variables for #{color repository.slug, :bold}", :info)
env_vars.each { |v| say "#{v.name}=" << color(v.value || "[secure]", :bold) }
end
|
#remove_vars ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/travis/cli/env.rb', line 48
def remove_vars
env_vars.each do |var|
next if block_given? and not yield(var)
say color('[x] ', [:red, :bold]) + "removing environment variable #{color "$#{var.name}", :info}"
var.delete
end
end
|
#set(name, value) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/travis/cli/env.rb', line 21
def set(name, value)
options ||= { :public => public } if public != nil
say color('[+] ', [:green, :bold]) + "setting environment variable #{color "$#{name}", :info}"
value = Shellwords.escape(value) unless unescape?
env_vars.upsert(name, value, options || {})
end
|
#setup ⇒ Object
15
16
17
18
19
|
# File 'lib/travis/cli/env.rb', line 15
def setup
super
authenticate
error "not allowed to access environment variables for #{color(repository.slug, :bold)}" unless repository.admin?
end
|
#unset(*names) ⇒ Object
38
39
40
|
# File 'lib/travis/cli/env.rb', line 38
def unset(*names)
remove_vars { |var| names.include? var.name }
end
|