42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/udb/cli.rb', line 42
def cfg(name_or_path)
raise ArgumentError, "Spec directory does not exist: #{options[:std]}" unless File.directory?(options[:std])
cfg_file =
if File.file?(name_or_path)
Pathname.new(name_or_path)
elsif File.file?("#{options[:config_dir]}/#{name_or_path}.yaml")
Pathname.new("#{options[:config_dir]}/#{name_or_path}.yaml")
else
raise ArgumentError, "Cannot find config: #{name_or_path}"
end
result = ConfiguredArchitecture.validate(cfg_file)
cfg_spec = YAML.load_file(cfg_file)
if result
say "Config #{cfg_spec.fetch('name')} is valid"
else
say "Config #{cfg_spec.fetch('name')} is invalid"
exit 1
end
end
|