Class: FPM::Cookery::CLI::Command
Instance Method Summary
collapse
Instance Method Details
#config ⇒ Object
87
88
89
|
# File 'lib/fpm/cookery/cli.rb', line 87
def config
@config ||= FPM::Cookery::Config.from_cli(self)
end
|
#execute ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/fpm/cookery/cli.rb', line 64
def execute
show_version if version?
init_logging
validate
FPM::Cookery::BaseRecipe.send(:include, FPM::Cookery::BookHook)
FPM::Cookery::Book.instance.load_recipe(recipe_file, config) do |recipe|
packager = FPM::Cookery::Packager.new(recipe, config.to_hash)
packager.target = FPM::Cookery::Facts.target.to_s
exec(config, recipe, packager)
end
end
|
#init_logging ⇒ Object
91
92
93
94
95
96
97
98
99
|
# File 'lib/fpm/cookery/cli.rb', line 91
def init_logging
FPM::Cookery::Log.enable_debug(config.debug)
if config.color?
FPM::Cookery::Log.output(FPM::Cookery::Log::Output::ConsoleColor.new)
else
FPM::Cookery::Log.output(FPM::Cookery::Log::Output::Console.new)
end
end
|
#recipe_file ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/fpm/cookery/cli.rb', line 32
def recipe_file
file = File.expand_path(recipe)
if File.directory?(file) && File.exists?(File.join(file, 'recipe.rb'))
file = File.join(file, 'recipe.rb')
end
file
end
|
#show_version ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/fpm/cookery/cli.rb', line 79
def show_version
require 'fpm/version'
require 'fpm/cookery/version'
puts "fpm-cookery v#{FPM::Cookery::VERSION} (fpm v#{FPM::VERSION})"
exit 0
end
|
#validate ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/fpm/cookery/cli.rb', line 43
def validate
unless File.exists?(recipe_file)
Log.error 'No recipe.rb found in the current directory, abort.'
exit 1
end
if platform
FPM::Cookery::Facts.platform = platform
end
if target
FPM::Cookery::Facts.target = target
end
if FPM::Cookery::Facts.target.nil?
Log.error "No target given and we're unable to detect your platform"
exit 1
end
end
|