From 14c699be15e2bde57383fe61806349a6e2c46b8f Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Fri, 28 Feb 2025 16:58:14 -0600 Subject: [PATCH 1/3] csv-filter: add --row_sep --- bin/csv-filter | 6 ++++++ test/csv/test_csv_filter.rb | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/bin/csv-filter b/bin/csv-filter index 8eddc538..3c839c7c 100755 --- a/bin/csv-filter +++ b/bin/csv-filter @@ -37,6 +37,12 @@ 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 From 071deeb168c899873e37528648ea16e2a97dea49 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Sun, 2 Mar 2025 21:54:46 -0600 Subject: [PATCH 2/3] Update bin/csv-filter Co-authored-by: Sutou Kouhei --- bin/csv-filter | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/csv-filter b/bin/csv-filter index 3c839c7c..b014090f 100755 --- a/bin/csv-filter +++ b/bin/csv-filter @@ -38,8 +38,7 @@ parser.on('--output-row-sep=SEPARATOR', end parser.on('-r', '--row-sep=SEPARATOR', - 'Row separator string.' -) do |value| + 'Row separator string.') do |value| options[:row_sep] = value end From 185d2c3ddd5795701ee312304e4a9d2281072ecd Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Sun, 2 Mar 2025 21:54:56 -0600 Subject: [PATCH 3/3] Update bin/csv-filter Co-authored-by: Sutou Kouhei --- bin/csv-filter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/csv-filter b/bin/csv-filter index b014090f..3c077650 100755 --- a/bin/csv-filter +++ b/bin/csv-filter @@ -40,7 +40,7 @@ end parser.on('-r', '--row-sep=SEPARATOR', 'Row separator string.') do |value| options[:row_sep] = value - end +end begin parser.parse!