Class: FPM::Cookery::CLI::Command
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.add_recipe_parameter! ⇒ Object
55
56
57
|
# File 'lib/fpm/cookery/cli.rb', line 55
def self.add_recipe_parameter!
parameter '[RECIPE]', 'the recipe file', :default => 'recipe.rb'
end
|
Instance Method Details
#config ⇒ Object
115
116
117
|
# File 'lib/fpm/cookery/cli.rb', line 115
def config
@config ||= FPM::Cookery::Config.from_cli(self)
end
|
#execute ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/fpm/cookery/cli.rb', line 90
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
rescue Error::ExecutionFailure, Error::Misconfiguration
exit 1
end
|
#init_logging ⇒ Object
119
120
121
122
123
124
125
126
127
|
# File 'lib/fpm/cookery/cli.rb', line 119
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
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/fpm/cookery/cli.rb', line 59
def recipe_file
file = File.expand_path(recipe)
if File.directory?(file) && File.exist?(File.join(file, 'recipe.rb'))
file = File.join(file, 'recipe.rb')
end
file
end
|
#show_version ⇒ Object
107
108
109
110
111
112
113
|
# File 'lib/fpm/cookery/cli.rb', line 107
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/fpm/cookery/cli.rb', line 70
def validate
unless File.exist?(recipe_file)
Log.error 'No recipe.rb found in the current directory, abort.'
exit 1
end
if platform.nil?
config.platform = FPM::Cookery::Facts.platform
else
FPM::Cookery::Facts.platform = platform
end
if target.nil?
config.target = FPM::Cookery::Facts.target
else
FPM::Cookery::Facts.target = target
end
end
|