Sha256: 1dbb290841695a281e5e29a65cfdfd68ab24620e447bf65162af3d4e6e0c81c8

Contents?: true

Size: 1.27 KB

Versions: 71

Compression:

Stored size: 1.27 KB

Contents

# encoding: UTF-8

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

71 entries across 71 versions & 1 rubygems

Version Path
bolognese-0.10.21 lib/bolognese/cli.rb
bolognese-0.10.20 lib/bolognese/cli.rb
bolognese-0.10.19 lib/bolognese/cli.rb
bolognese-0.10.18 lib/bolognese/cli.rb
bolognese-0.10.17 lib/bolognese/cli.rb
bolognese-0.10.16 lib/bolognese/cli.rb
bolognese-0.10.15 lib/bolognese/cli.rb
bolognese-0.10.14 lib/bolognese/cli.rb
bolognese-0.10.13 lib/bolognese/cli.rb
bolognese-0.10.11 lib/bolognese/cli.rb
bolognese-0.10.10 lib/bolognese/cli.rb
bolognese-0.10.9 lib/bolognese/cli.rb
bolognese-0.10.8 lib/bolognese/cli.rb
bolognese-0.10.7 lib/bolognese/cli.rb
bolognese-0.10.6 lib/bolognese/cli.rb
bolognese-0.10.5 lib/bolognese/cli.rb
bolognese-0.10.4 lib/bolognese/cli.rb
bolognese-0.10.3 lib/bolognese/cli.rb
bolognese-0.10.2 lib/bolognese/cli.rb
bolognese-0.10 lib/bolognese/cli.rb