Class: Builderator::Tasks::CLI
Overview
Top-level command line tasks
Constant Summary
collapse
- VERSION =
['--version', '-v'].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
#run, #run_with_input, #run_without_bundler, #template, #thor_run
Constructor Details
#initialize(*_) ⇒ CLI
Returns a new instance of CLI.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/builderator/tasks.rb', line 25
def initialize(*_)
super
ignore_existing_config = ['help'] + VERSION
return if ignore_existing_config.any? do |i|
ARGV.include?(i) || ARGV.empty?
end
Config.argv(options) Config.load(File.join(ENV['HOME'], '.builderator/Buildfile'))
Config.load(Util.relative_path('Buildfile').to_s)
Config.compile
end
|
Class Method Details
.exit_on_failure? ⇒ Boolean
45
46
47
|
# File 'lib/builderator/tasks.rb', line 45
def self.exit_on_failure?
true
end
|
Instance Method Details
#cleanup ⇒ Object
Globally enable/disable workspace cleanup
50
|
# File 'lib/builderator/tasks.rb', line 50
class_option 'cleanup', :type => :boolean, :default => true
|
#config(key = nil) ⇒ Object
114
|
# File 'lib/builderator/tasks.rb', line 114
desc 'config', 'Print compiled configuration'
|
#container(profile = :docker) ⇒ Object
96
97
98
99
100
|
# File 'lib/builderator/tasks.rb', line 96
def container(profile = :docker)
prepare
invoke Tasks::Packer, :build, [profile], options
end
|
#ec2(*args) ⇒ Object
77
78
79
80
|
# File 'lib/builderator/tasks.rb', line 77
def ec2(*args)
prepare
invoke Tasks::Vagrant, :ec2, args, options
end
|
#generate(project = :default) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/builderator/tasks.rb', line 149
def generate(project = :default)
fail 'Please provide a valid build name with the `--build-name=VALUE` option!' unless Config.has?(:build_name)
Config.generator.project.use(project)
Config.generator.project.current.resource.each do |rname, resource|
next if (options['ignore'] && options['ignore'].include?(rname.to_s)) ||
resource.action == :ignore
if (options['sync'] && options['sync'].include?(rname.to_s)) ||
resource.action == :sync
template resource.template, resource.path.first
next
end
if (options['rm'] && options['rm'].include?(rname.to_s)) ||
resource.action == :rm
resource.path.each { |rm| remove_file rm }
next
end
template resource.template, resource.path.first, :skip => true
end
end
|
#image(profile = :default) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/builderator/tasks.rb', line 86
def image(profile = :default)
prepare
invoke Tasks::Packer, :build, [profile], options
invoke Tasks::Packer, :copy, [profile], options if options['copy']
invoke Tasks::Packer, :remote_tag, [profile], options if options['remote_tag']
end
|
#local(*args) ⇒ Object
71
72
73
74
|
# File 'lib/builderator/tasks.rb', line 71
def local(*args)
prepare
invoke Tasks::Vagrant, :local, args, options
end
|
#prepare ⇒ Object
Tasks common to local, ec2, and ami builds
55
|
# File 'lib/builderator/tasks.rb', line 55
desc 'prepare', 'Common preparation tasks for Vagrant and Packer'
|
#print_version ⇒ Object
41
42
43
|
# File 'lib/builderator/tasks.rb', line 41
def print_version
say Gem.loaded_specs['builderator'].version
end
|