diff --git a/bin/csv-filter b/bin/csv-filter index 8eddc538..3c077650 100755 --- a/bin/csv-filter +++ b/bin/csv-filter @@ -37,6 +37,11 @@ parser.on('--output-row-sep=SEPARATOR', options[:output_row_sep] = value end +parser.on('-r', '--row-sep=SEPARATOR', + 'Row separator string.') do |value| + options[:row_sep] = value +end + begin parser.parse! rescue OptionParser::InvalidOption diff --git a/test/csv/test_csv_filter.rb b/test/csv/test_csv_filter.rb index dc9f432a..89446bf2 100644 --- a/test/csv/test_csv_filter.rb +++ b/test/csv/test_csv_filter.rb @@ -95,4 +95,14 @@ def test_option_output_row_sep assert_equal(["aaa,bbb,ccc:ddd,eee,fff:", ""], run_csv_filter(csv, "--output-row-sep=:")) end + + def test_option_row_sep + csv = "aaa,bbb,ccc:ddd,eee,fff:" + assert_equal(["aaa,bbb,ccc:ddd,eee,fff:", ""], + run_csv_filter(csv, "--row-sep=:")) + assert_equal(["aaa,bbb,ccc.ddd,eee,fff.", ""], + run_csv_filter(csv, "--row-sep=.", "--input-row-sep=:")) + assert_equal(["aaa,bbb,ccc.ddd,eee,fff.", ""], + run_csv_filter(csv, "--row-sep=:", "--output-row-sep=.")) + end end