From c90be16b646616a57a3e0a8219fd1555bdf3df2e Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 27 Feb 2025 13:52:31 -0600 Subject: [PATCH] Add option --output_row_sep to csv-filter --- bin/csv-filter | 5 +++++ test/csv/test_csv_filter.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/bin/csv-filter b/bin/csv-filter index bfa26e12..f0e86137 100755 --- a/bin/csv-filter +++ b/bin/csv-filter @@ -27,6 +27,11 @@ parser.on('--input-row-sep=SEPARATOR', options[:input_row_sep] = value end +parser.on('--output-row-sep=SEPARATOR', + 'Output row separator string.') do |value| + options[:output_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 95b82dbe..ad691921 100644 --- a/test/csv/test_csv_filter.rb +++ b/test/csv/test_csv_filter.rb @@ -83,4 +83,10 @@ def test_option_input_row_sep assert_equal(["aaa,bbb,ccc\nddd,eee,fff\n", ""], run_csv_filter(csv, "--input-row-sep=:")) end + + def test_option_output_row_sep + csv = "aaa,bbb,ccc\nddd,eee,fff\n" + assert_equal(["aaa,bbb,ccc:ddd,eee,fff:", ""], + run_csv_filter(csv, "--output-row-sep=:")) + end end