class Opener::OpinionDetectorBasic::CLI
CLI
wrapper around {Opener::OpinionDetectorBasic} using Slop.
@!attribute [r] parser
@return [Slop]
Attributes
parser[R]
Public Class Methods
new()
click to toggle source
# File lib/opener/opinion_detector_basic/cli.rb, line 12 def initialize @parser = configure_slop end
Public Instance Methods
configure_slop()
click to toggle source
@return [Slop]
# File lib/opener/opinion_detector_basic/cli.rb, line 26 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
run(argv = ARGV)
click to toggle source
@param [Array] argv
# File lib/opener/opinion_detector_basic/cli.rb, line 19 def run(argv = ARGV) parser.parse(argv) end