Class: Bosh::Cli::Command::Base
Direct Known Subclasses
Backup, Biff, BlobManagement, CloudCheck, Complete, Deployment, Errand, ExportCompiledPackages, Help, ImportCompiledPackages, Job, JobManagement, JobRename, LogManagement, Maintenance, Misc, Package, PropertyManagement, Release, Snapshot, Ssh, Stemcell, Task, User, Vm, Vms
Constant Summary
collapse
- DEFAULT_DIRECTOR_PORT =
25555
Instance Attribute Summary collapse
Instance Method Summary
collapse
desc, method_added, option, register_command, usage
#cancel_deployment, #deployment_changed?, #inspect_deployment_changes, #job_exists_in_deployment?, #job_must_exist_in_deployment, #job_unique_in_deployment?, #jobs_and_indexes, #latest_release_versions, #prepare_deployment_manifest, #prompt_for_job_and_index, #resolve_release_aliases
#major_version, #minor_version, #version_cmp, #version_greater, #version_less, #version_same
Constructor Details
#initialize(runner = nil, director = nil) ⇒ Base
15
16
17
18
19
20
21
22
23
|
# File 'lib/cli/base_command.rb', line 15
def initialize(runner = nil, director = nil)
@runner = runner
@director = director
@options = {}
@work_dir = Dir.pwd
@exit_code = 0
@out = nil
@args = []
end
|
Instance Attribute Details
Returns the value of attribute args.
9
10
11
|
# File 'lib/cli/base_command.rb', line 9
def args
@args
end
|
#exit_code ⇒ Object
Returns the value of attribute exit_code.
10
11
12
|
# File 'lib/cli/base_command.rb', line 10
def exit_code
@exit_code
end
|
Returns the value of attribute options.
9
10
11
|
# File 'lib/cli/base_command.rb', line 9
def options
@options
end
|
Returns the value of attribute out.
9
10
11
|
# File 'lib/cli/base_command.rb', line 9
def out
@out
end
|
Returns the value of attribute runner.
10
11
12
|
# File 'lib/cli/base_command.rb', line 10
def runner
@runner
end
|
Returns the value of attribute work_dir.
10
11
12
|
# File 'lib/cli/base_command.rb', line 10
def work_dir
@work_dir
end
|
Instance Method Details
#add_option(name, value) ⇒ Object
35
36
37
|
# File 'lib/cli/base_command.rb', line 35
def add_option(name, value)
@options[name] = value
end
|
#blob_manager ⇒ Object
54
55
56
|
# File 'lib/cli/base_command.rb', line 54
def blob_manager
@blob_manager ||= Bosh::Cli::BlobManager.new(release)
end
|
#blobstore ⇒ Object
58
59
60
|
# File 'lib/cli/base_command.rb', line 58
def blobstore
release.blobstore
end
|
26
27
28
29
30
31
32
33
|
# File 'lib/cli/base_command.rb', line 26
def config
@config ||= begin
env_bosh_config = ENV['BOSH_CONFIG'].to_s.empty? ? nil : ENV['BOSH_CONFIG']
config_file = options[:config] || env_bosh_config || Bosh::Cli::DEFAULT_CONFIG_PATH
Bosh::Cli::Config.new(config_file)
end
end
|
#confirmed?(question = 'Are you sure?') ⇒ Boolean
82
83
84
85
|
# File 'lib/cli/base_command.rb', line 82
def confirmed?(question = 'Are you sure?')
return true if non_interactive?
ask("#{question} (type 'yes' to continue): ") == 'yes'
end
|
#deployment ⇒ String
96
97
98
|
# File 'lib/cli/base_command.rb', line 96
def deployment
options[:deployment] || config.deployment
end
|
43
44
45
46
|
# File 'lib/cli/base_command.rb', line 43
def director
@director ||= Bosh::Cli::Client::Director.new(
target, username, password, @options.select { |k, _| k == :no_track })
end
|
#interactive? ⇒ Boolean
70
71
72
|
# File 'lib/cli/base_command.rb', line 70
def interactive?
!non_interactive?
end
|
#logged_in? ⇒ Boolean
62
63
64
|
# File 'lib/cli/base_command.rb', line 62
def logged_in?
!!(username && password)
end
|
#non_interactive? ⇒ Boolean
66
67
68
|
# File 'lib/cli/base_command.rb', line 66
def non_interactive?
options[:non_interactive]
end
|
106
107
108
|
# File 'lib/cli/base_command.rb', line 106
def password
options[:password] || ENV['BOSH_PASSWORD'] || config.password(target)
end
|
#redirect(*args) ⇒ Object
78
79
80
|
# File 'lib/cli/base_command.rb', line 78
def redirect(*args)
Bosh::Cli::Runner.new(args, @options).run
end
|
48
49
50
51
52
|
# File 'lib/cli/base_command.rb', line 48
def release
return @release if @release
check_if_release_dir
@release = Bosh::Cli::Release.new(@work_dir)
end
|
#remove_option(name) ⇒ Object
39
40
41
|
# File 'lib/cli/base_command.rb', line 39
def remove_option(name)
@options.delete(name)
end
|
#target ⇒ String
Also known as:
target_url
88
89
90
91
92
|
# File 'lib/cli/base_command.rb', line 88
def target
raw_url = options[:target] || config.target
url = config.resolve_alias(:target, raw_url) || raw_url
url ? normalize_url(url) : nil
end
|
#target_name ⇒ Object
110
111
112
|
# File 'lib/cli/base_command.rb', line 110
def target_name
options[:target] || config.target_name || target_url
end
|
101
102
103
|
# File 'lib/cli/base_command.rb', line 101
def username
options[:username] || ENV['BOSH_USER'] || config.username(target)
end
|
#verbose? ⇒ Boolean
74
75
76
|
# File 'lib/cli/base_command.rb', line 74
def verbose?
@options[:verbose]
end
|