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, #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, #logout, #regenerate_token, #remove_token, #repo, #repos, #restart, #user
Methods inherited from Command
abstract, abstract?, #check_completion, #check_ruby, #check_version, #command_name, command_name, #debug?, description, #error, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, skip, subcommands, #terminal, #time, #usage, #usage_for, #warn, #write_to
asset, asset_path
Methods included from Parser
#new, #on, #on_initialize
Instance Method Details
#clear ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/travis/cli/env.rb', line 44
def clear
exit if env_vars.empty?
exit 1 if interactive? && !force? && !danger_zone?("Clear out all env variables for #{color(
repository.slug, :bold
)}?")
remove_vars
end
|
#copy(*names) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/travis/cli/env.rb', line 30
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
66
67
68
|
# File 'lib/travis/cli/env.rb', line 66
def env_vars
repository.env_vars
end
|
#list ⇒ Object
61
62
63
64
|
# File 'lib/travis/cli/env.rb', line 61
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
52
53
54
55
56
57
58
59
|
# File 'lib/travis/cli/env.rb', line 52
def remove_vars
env_vars.each do |var|
next if block_given? && !yield(var)
say color('[x] ', %i[red bold]) + "removing environment variable #{color "$#{var.name}", :info}"
var.delete
end
end
|
#set(name, value) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/travis/cli/env.rb', line 23
def set(name, value)
options ||= { public: } unless public.nil?
say color('[+] ', %i[green bold]) + "setting environment variable #{color "$#{name}", :info}"
value = Shellwords.escape(value) unless unescape?
env_vars.upsert(name, value, options || {})
end
|
#setup ⇒ Object
17
18
19
20
21
|
# File 'lib/travis/cli/env.rb', line 17
def setup
super
authenticate
error "not allowed to access environment variables for #{color(repository.slug, :bold)}" unless repository.push?
end
|
#unset(*names) ⇒ Object
40
41
42
|
# File 'lib/travis/cli/env.rb', line 40
def unset(*names)
remove_vars { |var| names.include? var.name }
end
|