lib/kameleon/cli.rb in kameleon-builder-2.3.5 vs lib/kameleon/cli.rb in kameleon-builder-2.4.0
- old
+ new
@@ -54,32 +54,37 @@
unless template_name.end_with? '.yaml'
template_path = template_path + '.yaml'
end
begin
tpl = RecipeTemplate.new(template_path)
+ tpl.resolve!
rescue
raise TemplateNotFound, "Template '#{template_name}' not found. " \
"To see all templates, run the command "\
"`kameleon template ls`"
else
- files2copy = tpl.base_recipes_files + tpl.files
+ files2copy = tpl.base_recipes_files + tpl.files + tpl.data
files2copy.each do |path|
relative_path = path.relative_path_from(Kameleon.env.repositories_path)
dst = File.join(Kameleon.env.workspace, relative_path)
copy_file(path, dst)
end
end
end
desc "info [TEMPLATE_NAME]", "Display detailed information about a template"
+ method_option :global, :type => :hash ,
+ :default => {}, :aliases => "-g",
+ :desc => "Set custom global variables."
def info(template_name)
Kameleon.env.root_dir = Kameleon.env.repositories_path
template_path = File.join(Kameleon.env.repositories_path, template_name)
unless template_name.end_with? '.yaml'
template_path = template_path + '.yaml'
end
tpl = RecipeTemplate.new(template_path)
+ tpl.resolve!
tpl.display_info
end
map %w(-h --help) => :help
map %w(ls) => :list
end
@@ -87,10 +92,11 @@
class Main < Thor
include Thor::Actions
+ register CLI::Repository, 'repository', 'repository', 'Manages set of remote git repositories'
# register CLI::Recipe, 'recipe', 'recipe', 'Manages the local recipes'
register CLI::Template, 'template', 'template', 'Lists and imports templates'
class_option :color, :type => :boolean, :default => Kameleon.default_values[:color],
:desc => "Enables colorization in output"
@@ -136,16 +142,17 @@
recipe_path = Pathname.new(Kameleon.env.workspace).join(recipe_path).to_path
begin
tpl = Kameleon::RecipeTemplate.new(template_path)
+ tpl.resolve!
rescue
raise TemplateNotFound, "Template '#{template_name}' not found. " \
"To see all templates, run the command "\
"`kameleon templates`"
else
- files2copy = tpl.base_recipes_files + tpl.files
+ files2copy = tpl.base_recipes_files + tpl.files + tpl.data
files2copy.each do |path|
relative_path = path.relative_path_from(Kameleon.env.repositories_path)
dst = File.join(Kameleon.env.workspace, relative_path)
copy_file(path, dst)
end
@@ -162,12 +169,16 @@
end
end
end
desc "info [RECIPE_PATH]", "Display detailed information about a recipe"
+ method_option :global, :type => :hash ,
+ :default => {}, :aliases => "-g",
+ :desc => "Set custom global variables."
def info(recipe_path)
recipe = Kameleon::Recipe.new(recipe_path)
+ recipe.resolve!
recipe.display_info
end
desc "build [[RECIPE_PATH]]", "Builds the appliance from the given recipe"
method_option :build_path, :type => :string ,
@@ -193,10 +204,12 @@
:default => nil,
:desc => "Uses a persistent cache tar file to build the image."
method_option :proxy_path, :type => :string ,
:default => nil,
:desc => "Full path of the proxy binary to use for the persistent cache."
-
+ method_option :global, :type => :hash,
+ :default => {}, :aliases => "-g",
+ :desc => "Set custom global variables."
def build(recipe_path=nil)
if recipe_path.nil? && !options[:from_cache].nil?
Kameleon.ui.info("Using the cached recipe")
@cache = Kameleon::Persistent_cache.instance
@cache.cache_path = options[:from_cache]