Sha256: 789a9bb5a4bb149cff5a1385236452460ee6e4aa7947ba0909585e3048c98802

Contents?: true

Size: 949 Bytes

Versions: 4

Compression:

Stored size: 949 Bytes

Contents

# Allow (or create) directories that are already bootstrapped. Handy to allow "bootstrap once, build many"
# to save time when diffing multiple catalogs on this system.
# @param parser [OptionParser object] The OptionParser argument
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:bootstrapped_dirs) do
  has_weight 60

  def parse(parser, options)
    these_options = { 'from' => :bootstrapped_from_dir, 'to' => :bootstrapped_to_dir }
    these_options.each do |tag, hash_key|
      parser.on("--bootstrapped-#{tag}-dir DIRNAME", "Use a pre-bootstrapped '#{tag}' directory") do |dir|
        options[hash_key] = File.absolute_path(dir)
        Dir.mkdir options[hash_key], 0o700 unless Dir.exist?(options[hash_key])
        raise "Invalid bootstrapped-#{tag}-dir: does not exist" unless Dir.exist?(options[hash_key])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
octocatalog-diff-0.5.6 lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb
octocatalog-diff-0.5.4 lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb
octocatalog-diff-0.5.3 lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb
octocatalog-diff-0.5.1 lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb