8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/hammer_cli_katello/content_import.rb', line 8
def self.included(base)
base.option "--metadata-file",
"METADATA_FILE", _("Location of the metadata.json file. "\
"This is not required if the metadata.json file"\
" is already in the archive directory."),
:attribute_name => :option_metadata_file,
:required => false
base.build_options do |o|
o.expand(:all).including(:organizations).except(:metadata)
end
base.validate_options do
option(:option_path).required
metadata_file = option(:option_metadata_file).value ||
File.join(option(:option_path).value, "metadata.json")
begin
URI.open(metadata_file)
rescue Errno::ENOENT
msg = _("Unable to find '#{metadata_file}'. "\
"If the metadata.json file is at a different location "\
"provide it to the --metadata-file option ")
raise HammerCLI::Options::Validators::ValidationError, msg
end
end
base.success_message _("Archive is being imported in task %{id}.")
base.failure_message _("Could not import the archive.")
end
|