Class: Opener::TreeTagger::CLI
- Inherits:
-
Object
- Object
- Opener::TreeTagger::CLI
- Defined in:
- lib/opener/tree_tagger/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#option_parser ⇒ Object
readonly
Returns the value of attribute option_parser.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv, options = {}) ⇒ CLI
constructor
A new instance of CLI.
- #run(input) ⇒ Object
Constructor Details
#initialize(argv, options = {}) ⇒ CLI
Returns a new instance of CLI.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/opener/tree_tagger/cli.rb', line 10 def initialize(argv, = {}) @argv = argv @options = DEFAULT_OPTIONS.merge() @option_parser = OptionParser.new do |opts| opts.program_name = 'tree-tagger' opts.summary_indent = ' ' opts.separator "\nOptions:\n\n" opts.on('-l', '--log', 'Enable logging to STDERR') do @options[:logging] = true end opts.on('--no-time', 'Disables adding of timestamps') do @options[:args] << '--no-time' end opts.separator <<-EOF Examples: cat example.kaf | #{opts.program_name} # Basic usage cat example.kaf | #{opts.program_name} -l # Logs information to STDERR EOF end end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
4 5 6 |
# File 'lib/opener/tree_tagger/cli.rb', line 4 def argv @argv end |
#option_parser ⇒ Object (readonly)
Returns the value of attribute option_parser.
4 5 6 |
# File 'lib/opener/tree_tagger/cli.rb', line 4 def option_parser @option_parser end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/opener/tree_tagger/cli.rb', line 4 def @options end |
Instance Method Details
#run(input) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/opener/tree_tagger/cli.rb', line 41 def run(input) option_parser.parse!(argv) tagger = TreeTagger.new() puts tagger.run(input) end |