Sha256: 092ae5cd8ce43b1f8e0278497763c94a98d0dc4eded9a709cd413f6d1652c9bc
Contents?: true
Size: 1.74 KB
Versions: 3
Compression:
Stored size: 1.74 KB
Contents
# frozen_string_literal: true require 'thor' require_relative 'doi_utils' require_relative 'utils' module Briard class CLI < Thor include Briard::DoiUtils include Briard::Utils def self.exit_on_failure? true end # from http://stackoverflow.com/questions/22809972/adding-a-version-option-to-a-ruby-thor-cli map %w[--version -v] => :__print_version desc '--version, -v', 'print the version' def __print_version puts Briard::VERSION end desc '', 'convert metadata' method_option :from, aliases: '-f' method_option :to, aliases: '-t', default: 'schema_org' method_option :regenerate, type: :boolean, force: false method_option :style, aliases: '-s', default: 'apa' method_option :locale, aliases: '-l', default: 'en-US' method_option :show_errors, type: :boolean, force: false method_option :depositor method_option :email method_option :registrant def convert(input) metadata = Metadata.new(input: input, from: options[:from], regenerate: options[:regenerate], style: options[:style], locale: options[:locale], show_errors: options[:show_errors], depositor: options[:depositor], email: options[:email], registrant: options[:registrant]) to = options[:to] || 'schema_org' if options[:show_errors] && !metadata.valid? warn metadata.errors else puts metadata.send(to) end end desc '', 'encode' def encode(prefix) puts encode_doi(prefix) end default_task :convert end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
briard-2.6.2 | lib/briard/cli.rb |
briard-2.6.1 | lib/briard/cli.rb |
briard-2.6.0 | lib/briard/cli.rb |