/usr/lib/ruby/vendor_ruby/octocatalog-diff/cli/options/save_catalog.rb is in octocatalog-diff 1.5.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 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 | # frozen_string_literal: true
# Allow catalogs to be saved to a file before they are diff'd.
# @param parser [OptionParser object] The OptionParser argument
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:save_catalog) do
has_weight 155
def parse(parser, options)
OctocatalogDiff::Cli::Options.option_globally_or_per_branch(
parser: parser,
options: options,
cli_name: 'save-catalog',
option_name: 'save_catalog',
desc: 'Save intermediate catalogs into files',
datatype: '',
validator: lambda do |catalog_file|
target_dir = File.dirname(catalog_file)
unless File.directory?(target_dir)
raise Errno::ENOENT, "Cannot save catalog to #{catalog_file} because parent directory does not exist"
end
if File.exist?(catalog_file) && !File.file?(catalog_file)
raise ArgumentError, "Cannot overwrite #{catalog_file} which is not a file"
end
true
end,
post_process: lambda do |opts|
if opts[:to_save_catalog] && opts[:to_save_catalog] == opts[:from_save_catalog]
raise ArgumentError, 'Cannot use the same file for --to-save-catalog and --from-save-catalog'
end
end
)
end
end
|