diff --git a/sorter.rb b/sorter.rb index 4b3ed17..9d3ca45 100755 --- a/sorter.rb +++ b/sorter.rb @@ -20,6 +20,7 @@ require 'json' require 'pp' require 'csv' +require 'optparse' #bin_counter expects: # bin - a hash with strings to search for @@ -62,8 +63,18 @@ def strip_text (text, start, fin) text.lines(start,chomp: true)[1].lines(fin,chomp: true)[0] end +options = Hash.new +OptionParser.new do |opts| + opts.banner = 'sorter.rb --options' + opts.on("-f", "--file file", "Name of the file to process") do |file| + options[:file] = file + end +end.parse! + + csv = CSV.read('./bins.csv') text = File.read('tester.txt') +text = File.read(options[:file]) text = strip_text(text,'PLOVEINTAKE','PLOVECLOSING') output = Hash.new #Creating the output storage object bins = Hash.new #This hash stores the bins