Sha256: fe7a175577e551b53e3ef43f06870d2460d881b4af336a6825b41e70d7a87fc9

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

module Opener
  class Ned
    ##
    # CLI wrapper around {Opener::Ned} using Slop.
    #
    # @!attribute [r] parser
    #  @return [Slop]
    #
    class CLI
      attr_reader :parser

      def initialize
        @parser = configure_slop
      end

      ##
      # @param [Array] argv
      #
      def run(argv = ARGV)
        parser.parse(argv)
      end

      ##
      # @return [Slop]
      #
      def configure_slop
        return Slop.new(:strict => false, :indent => 2, :help => true) do
          banner 'Usage: ner [OPTIONS]'

          separator <<-EOF.chomp

About:

    Named Entity Disambiguation for various languages using DBPedia.
    This command reads input from STDIN.

Example:

    cat some_file.kaf | ned
          EOF

          separator "\nOptions:\n"

          on :v, :version, 'Shows the current version' do
            abort "ned v#{VERSION} on #{RUBY_DESCRIPTION}"
          end

          on :l, :logging, 'Enables debug logging output',
            :default => false

          on :'disable-time', 'Disables adding of dynamic timestamps',
            :default => false

          run do |opts, args|
            ned = Ned.new(
              :args        => args,
              :logging     => opts[:logging],
              :enable_time => !opts[:'disable-time']
            )

            input = STDIN.tty? ? nil : STDIN.read

            puts ned.run(input)
          end
        end
      end
    end # CLI
  end # Ned
end # Opener

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opener-ned-3.0.0 lib/opener/ned/cli.rb