Sha256: d9d6c3227f396a3c6f46460db14fafd242b29df82277971e4fac73d846375e6e

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'opener/core'

module Opener
  class PolarityTagger
    ##
    # CLI wrapper around {Opener::LanguageIdentifier} 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: polarity-tagger [OPTIONS] -- [PYTHON OPTIONS]'

          separator <<-EOF.chomp

About:

    Component for tagging the polarity of elements in a KAF document. This
    command reads input from STDIN.

Examples:

    Processing a KAF file:

        cat some_file.kaf | polarity-tagger

    Displaying the underlying kernel options:

        polarity-tagger -- --help

          EOF

          separator "\nOptions:\n"

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

          run do |opts, args|
            tagger = PolarityTagger.new(:args => args)
            input  = STDIN.tty? ? nil : STDIN.read

            puts tagger.run(input)
          end
        end
      end
    end # CLI
  end # PolarityTagger
end # Opener

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opener-polarity-tagger-3.0.1 lib/opener/polarity_tagger/cli.rb
opener-polarity-tagger-3.0.0 lib/opener/polarity_tagger/cli.rb