Sha256: ad70b507421e5018c2522c34409f2c4a30dd0aa7972fe8742a236f6ed6b7f83b

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

#!/usr/bin/env ruby

require 'i18n'
require 'ddr/ingesttools'
require 'optparse'

options = {}

puts I18n.t('marquee')
puts I18n.t('suite.name', version: Ddr::IngestTools::VERSION)
puts I18n.t('manifest_ark_minter.name')
puts I18n.t('marquee')

# Parse command line arguments
parser = OptionParser.new do |opts|
  opts.banner = 'Usage: mint_manifest_arks.rb [options]'

  opts.on('-c', '--config CONFIG_FILE', 'Path to configuration file') do |v|
    options[:config] = v
  end

  opts.on('-m', '--manifest MANIFEST_FILE', 'Path to manifest file for which ARKs are to be minted') do |v|
    options[:manifest] = v
  end

  opts.on('-o', '--output OUTPUT_FILE', 'Path to which updated manifest file should be written') do |v|
    options[:output] = v
  end
end

begin
  parser.parse!
  if options['config'].nil?
    puts I18n.t('manifest_ark_minter.use_default_config_file',
                default_config_file: Ddr::IngestTools::ManifestArkMinter::ManifestUpdater::DEFAULT_CONFIG_FILE)
  end
  mandatory = [ :manifest, :output ]
  missing = mandatory.select{ |param| options[param].nil? }
  unless missing.empty?
    raise OptionParser::MissingArgument.new(missing.join(', '))
  end
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
  puts $!.to_s
  puts parser
  exit(false)
end

updater = Ddr::IngestTools::ManifestArkMinter::ManifestUpdater.new(options)
updater.call

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddr-ingesttools-0.6.1 bin/mint_manifest_arks.rb
ddr-ingesttools-0.6.0 bin/mint_manifest_arks.rb