Sha256: 32fa44db9a3f8c79cdafed25144345c244602826a2c2a03f246ba59c95d026a8

Contents?: true

Size: 1.59 KB

Versions: 14

Compression:

Stored size: 1.59 KB

Contents

module Opener
  class OpinionDetectorBasic
    ##
    # CLI wrapper around {Opener::OpinionDetectorBasic} 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: opinion-detector-basic [OPTIONS]'

          separator <<-EOF.chomp

About:

    Rule based opinion detection for various languages such as Dutch and
    English. This command reads input from STDIN.

Example:

    cat some_file.kaf | opinion-detector-basic
          EOF

          separator "\nOptions:\n"

          on :v, :version, 'Shows the current version' do
            abort "opinion-detector-basic v#{VERSION} on #{RUBY_DESCRIPTION}"
          end

          on :p, :pretty, 'Enables pretty-printing of XML',
            :default => false

          on :'no-timestamp', 'Disables timestamps in XML output'

          run do |opts, args|
            detector = OpinionDetectorBasic.new(
              :args      => args,
              :domain    => opts[:domain],
              :pretty    => opts[:pretty],
              :timestamp => !opts[:'no-timestamp']
            )

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

            puts detector.run(input)
          end
        end
      end
    end # CLI
  end # OpinionDetectorBasic
end # Opener

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
opener-opinion-detector-basic-3.3.0 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.8 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.7 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.6 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.5 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.4 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.3 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.2 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.1 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.2.0 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.1.2 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.1.1 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.1.0 lib/opener/opinion_detector_basic/cli.rb
opener-opinion-detector-basic-3.0.2 lib/opener/opinion_detector_basic/cli.rb