From e586cfa0bc6e0ffb7e9a0a522e272e7c7717b1bf Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Wed, 26 Feb 2025 14:36:31 -0600 Subject: [PATCH] Add option --input_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 c5328171..bfa26e12 100755 --- a/bin/csv-filter +++ b/bin/csv-filter @@ -22,6 +22,11 @@ parser.on('--input-col-sep=SEPARATOR', options[:input_col_sep] = value end +parser.on('--input-row-sep=SEPARATOR', + 'Input row separator string.') do |value| + options[:input_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 01e39071..95b82dbe 100644 --- a/test/csv/test_csv_filter.rb +++ b/test/csv/test_csv_filter.rb @@ -77,4 +77,10 @@ def test_option_input_col_sep assert_equal(["aaa,bbb,ccc\nddd,eee,fff\n", ""], run_csv_filter(csv, "--input-col-sep=:")) end + + def test_option_input_row_sep + csv = "aaa,bbb,ccc:ddd,eee,fff:" + assert_equal(["aaa,bbb,ccc\nddd,eee,fff\n", ""], + run_csv_filter(csv, "--input-row-sep=:")) + end end