bin/masticate in masticate-0.1.0 vs bin/masticate in masticate-0.1.1

- old
+ new

@@ -35,64 +35,58 @@ end opts.on("--to STRING", "Result string for gsub conversion") do |s| options[:to] = s end + + opts.on("--inlined", "(for *mend* only) Source file has headers inlined on each line") do |v| + options[:inlined] = v + end end.parse! filename = ARGV.shift # use stdin if no filename provided +def logmessage(command, options, results) + $stderr.puts <<-EOT +* masticate #{command} (#{options.keys.join(', ')}) + Lines in input: #{results[:input_count]} + Lines in output: #{results[:output_count]} +EOT +end + case command when 'sniff' results = Masticate.sniff(filename) col_sep = results[:col_sep] col_sep = "TAB" if col_sep == "\t" + quote_char = results[:quote_char] || "NONE" $stderr.puts <<-EOT Processing complete. Input delimiter: #{col_sep} + Quote char: #{quote_char} Field counts: #{results[:field_counts].inspect} Headers: #{results[:headers].join(',')} EOT when 'mend' results = Masticate.mend(filename, options) - $stderr.puts <<-EOT -Processing complete. - Lines in input: #{results[:input_count]} - Lines in output: #{results[:output_count]} -EOT + logmessage(command, options, results) when 'csvify' results = Masticate.csvify(filename, options) - $stderr.puts <<-EOT -Processing complete. - Lines in input: #{results[:input_count]} - Lines in output: #{results[:output_count]} -EOT + logmessage(command, options, results) when 'pluck' results = Masticate.pluck(filename, options) - $stderr.puts <<-EOT -Processing complete. - Lines in input: #{results[:input_count]} - Lines in output: #{results[:output_count]} -EOT + logmessage(command, options, results) when 'datify' results = Masticate.datify(filename, options) - $stderr.puts <<-EOT -Processing complete. - Lines in input: #{results[:input_count]} - Lines in output: #{results[:output_count]} -EOT + logmessage(command, options, results) when 'gsub' results = Masticate.gsub(filename, options) -# $stderr.puts <<-EOT -# Processing complete. -# Lines in input: #{results[:input_count]} -# Lines in output: #{results[:output_count]} -# EOT + logmessage(command, options, results) else raise "unknown command #{command}" end