From 8f9d49184dba523b55e35f1c8b22ee7af81c36d2 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 27 Feb 2025 13:57:43 -0600 Subject: [PATCH] Add option --output_col_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..8a790b91 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-col-sep=SEPARATOR', + 'Output column separator string.') do |value| + options[:output_col_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..5e9f025f 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_col_sep + csv = "aaa,bbb,ccc\nddd,eee,fff\n" + assert_equal(["aaa:bbb:ccc\nddd:eee:fff\n", ""], + run_csv_filter(csv, "--output-col-sep=:")) + end end