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.2.15 lib/bolognese/cli.rb
bolognese-1.2.14 lib/bolognese/cli.rb
bolognese-1.2.11 lib/bolognese/cli.rb
bolognese-1.2.10 lib/bolognese/cli.rb
bolognese-1.2.9 lib/bolognese/cli.rb
bolognese-1.2.8 lib/bolognese/cli.rb
bolognese-1.2.7 lib/bolognese/cli.rb
bolognese-1.2.6 lib/bolognese/cli.rb
bolognese-1.2.5 lib/bolognese/cli.rb
bolognese-1.2.4 lib/bolognese/cli.rb
bolognese-1.2.3 lib/bolognese/cli.rb
bolognese-1.2.2 lib/bolognese/cli.rb
bolognese-1.2.1 lib/bolognese/cli.rb
bolognese-1.2 lib/bolognese/cli.rb
bolognese-1.1.17 lib/bolognese/cli.rb
bolognese-1.1.16 lib/bolognese/cli.rb
bolognese-1.1.15 lib/bolognese/cli.rb
bolognese-1.1.14 lib/bolognese/cli.rb
bolognese-1.1.13 lib/bolognese/cli.rb
bolognese-1.1.12 lib/bolognese/cli.rb