Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bin/csv-filter
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ parser.on('--input-col-sep=SEPARATOR',
options[:input_col_sep] = value
end

parser.on('--input-quote-char=SEPARATOR',
parser.on('--input-quote-char=CHAR',
'Input quote character.') do |value|
options[:input_quote_char] = value
end
Expand All @@ -37,7 +37,7 @@ parser.on('--output-col-sep=SEPARATOR',
options[:output_col_sep] = value
end

parser.on('--output-quote-char=SEPARATOR',
parser.on('--output-quote-char=CHAR',
'Output quote character.') do |value|
options[:output_quote_char] = value
end
Expand All @@ -52,6 +52,11 @@ parser.on('-r', '--row-sep=SEPARATOR',
options[:row_sep] = value
end

parser.on('-c', '--col-sep=SEPARATOR',
'Column separator string.') do |value|
options[:col_sep] = value
end

begin
parser.parse!
rescue OptionParser::InvalidOption
Expand Down
10 changes: 10 additions & 0 deletions test/csv/test_csv_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,14 @@ def test_option_row_sep
assert_equal(["aaa,bbb,ccc.ddd,eee,fff.", ""],
run_csv_filter(csv, "--row-sep=:", "--output-row-sep=."))
end

def test_option_col_sep
csv = "aaa:bbb:ccc\nddd:eee:fff\n"
assert_equal(["aaa:bbb:ccc\nddd:eee:fff\n", ""],
run_csv_filter(csv, "--col-sep=:"))
assert_equal(["aaa.bbb.ccc\nddd.eee.fff\n", ""],
run_csv_filter(csv, "--col-sep=.", "--input-col-sep=:"))
assert_equal(["aaa.bbb.ccc\nddd.eee.fff\n", ""],
run_csv_filter(csv, "--col-sep=:", "--output-col-sep=."))
end
end