lib/reckon/app.rb in reckon-0.6.1 vs lib/reckon/app.rb in reckon-0.6.2

- old
+ new

@@ -284,13 +284,13 @@ rows << row end print_transaction(rows) end - def self.parse_opts(args = ARGV) + def self.parse_opts(args=ARGV, stdin=STDIN) options = { :output_file => STDOUT } - parser = OptionParser.new do |opts| + OptionParser.new do |opts| opts.banner = "Usage: Reckon.rb [options]" opts.separator "" opts.on("-f", "--file FILE", "The CSV file to parse") do |file| options[:file] = file @@ -390,9 +390,18 @@ puts VERSION exit end opts.parse!(args) + end + + if options[:file] == '-' + unless options[:unattended] + raise "--unattended is required to use STDIN as CSV source." + end + + puts "Reading csv from STDIN" + options[:string] = stdin.read end unless options[:file] options[:file] = @@cli.ask("What CSV file should I parse? ") unless options[:file].length > 0