Sha256: 48a92e73f14315f69147ecf2a60116a374d850b67a0a40ffccffb5877372d688

Contents?: true

Size: 1.29 KB

Versions: 107

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8
# frozen_string_literal: true

require "thor"

require_relative 'doi_utils'
require_relative 'utils'

module Bolognese
  class CLI < Thor
    include Bolognese::DoiUtils
    include Bolognese::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 Bolognese::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"
    def convert(input)
      metadata = Metadata.new(input: input,
                              from: options[:from],
                              regenerate: options[:regenerate],
                              style: options[:style],
                              locale: options[:locale])
      to = options[:to] || "schema_org"

      if metadata.valid?
        puts metadata.send(to)
      else
        $stderr.puts metadata.errors
      end
    end

    default_task :convert
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
bolognese-1.3.19 lib/bolognese/cli.rb
bolognese-1.3.17 lib/bolognese/cli.rb
bolognese-1.3.16 lib/bolognese/cli.rb
bolognese-1.3.13 lib/bolognese/cli.rb
bolognese-1.3.11 lib/bolognese/cli.rb
bolognese-1.3.10 lib/bolognese/cli.rb
bolognese-1.3.9 lib/bolognese/cli.rb
bolognese-1.3.8 lib/bolognese/cli.rb
bolognese-1.3.7 lib/bolognese/cli.rb
bolognese-1.3.6 lib/bolognese/cli.rb
bolognese-1.3.5 lib/bolognese/cli.rb
bolognese-1.3.4 lib/bolognese/cli.rb
bolognese-1.3.3 lib/bolognese/cli.rb
bolognese-1.3.2 lib/bolognese/cli.rb
bolognese-1.3.1 lib/bolognese/cli.rb
bolognese-1.2.20 lib/bolognese/cli.rb
bolognese-1.2.19 lib/bolognese/cli.rb
bolognese-1.2.18 lib/bolognese/cli.rb
bolognese-1.2.17 lib/bolognese/cli.rb
bolognese-1.2.16 lib/bolognese/cli.rb