#!/usr/bin/env ruby require_relative "../lib/masticate" command, filename = ARGV case ARGV.shift when 'sniff' results = Masticate.sniff(filename) col_sep = results[:col_sep] col_sep = "TAB" if col_sep == "\t" $stderr.puts <<-EOT Processing complete. Input delimiter: #{col_sep} Field counts: #{results[:field_counts].inspect} EOT when 'mend' metadata = Masticate.sniff(filename) col_sep = metadata[:col_sep] col_sep = "TAB" if col_sep == "\t" results = Masticate.mend(filename, metadata) $stderr.puts <<-EOT Processing complete. Input delimiter: #{col_sep} Lines in input: #{results[:input_records]} Lines in output: #{results[:output_records]} EOT when 'csvify' metadata = Masticate.sniff(filename) results = Masticate.csvify(filename, metadata) $stderr.puts <<-EOT Processing complete. Input delimiter: #{metadata[:col_sep]} Lines in input: #{results[:input_count]} Lines in output: #{results[:output_count]} EOT else raise "unknown command #{command}" end