Class: FPM::Cookery::CLI::Command
- Inherits:
-
FPM::Cookery::CLI
- Object
- Clamp::Command
- FPM::Cookery::CLI
- FPM::Cookery::CLI::Command
- Defined in:
- lib/fpm/cookery/cli.rb
Direct Known Subclasses
Instance Method Summary collapse
- #config ⇒ Object
- #execute ⇒ Object
- #init_logging ⇒ Object
- #recipe_file ⇒ Object
- #show_version ⇒ Object
- #validate ⇒ Object
Instance Method Details
#config ⇒ Object
89 90 91 |
# File 'lib/fpm/cookery/cli.rb', line 89 def config @config ||= FPM::Cookery::Config.from_cli(self) end |
#execute ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fpm/cookery/cli.rb', line 66 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
93 94 95 96 97 98 99 100 101 |
# File 'lib/fpm/cookery/cli.rb', line 93 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
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fpm/cookery/cli.rb', line 34 def recipe_file file = File.(recipe) # Allow giving the directory containing a recipe.rb if File.directory?(file) && File.exists?(File.join(file, 'recipe.rb')) file = File.join(file, 'recipe.rb') end file end |
#show_version ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/fpm/cookery/cli.rb', line 81 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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fpm/cookery/cli.rb', line 45 def validate unless File.exists?(recipe_file) Log.error 'No recipe.rb found in the current directory, abort.' exit 1 end # Override the detected platform. 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 |