diff --git a/bin/csv-filter b/bin/csv-filter index 8eddc538..4121ee68 100755 --- a/bin/csv-filter +++ b/bin/csv-filter @@ -32,6 +32,11 @@ parser.on('--output-col-sep=SEPARATOR', options[:output_col_sep] = value end +parser.on('--output-quote-char=SEPARATOR', + 'Output quote character.') do |value| + options[:output_quote_char] = value +end + parser.on('--output-row-sep=SEPARATOR', 'Output row separator string.') do |value| options[:output_row_sep] = value diff --git a/test/csv/test_csv_filter.rb b/test/csv/test_csv_filter.rb index dc9f432a..c806358f 100644 --- a/test/csv/test_csv_filter.rb +++ b/test/csv/test_csv_filter.rb @@ -90,6 +90,13 @@ def test_option_output_col_sep run_csv_filter(csv, "--output-col-sep=:")) end + def test_option_output_quote_char + output_quote_char = "'" + csv = "foo,0\n'bar',1\n\"baz\",2\n" + assert_equal(["foo,0\n'''bar''',1\nbaz,2\n", ""], + run_csv_filter(csv, "--output-quote_char=#{output_quote_char}")) + end + def test_option_output_row_sep csv = "aaa,bbb,ccc\nddd,eee,fff\n" assert_equal(["aaa,bbb,ccc:ddd,eee,fff:", ""],