Accept hyphens as an output option

This commit is contained in:
kojix2 2021-06-07 23:51:46 +09:00
parent 7a1bacccbc
commit dfc027d972

View File

@ -38,13 +38,17 @@ module YouPlot
parser.on_tail('') # Add a blank line at the end
parser.separator('')
parser.on('Common options:')
parser.on('-O', '--pass [FILE]', 'file to output input data to [stdout]',
'for inserting YouPlot in the middle of Unix pipes') do |v|
options[:pass] = v || $stdout
end
parser.on('-o', '--output [FILE]', 'file to output plots to [stdout]',
'If no option is specified, plot will print to stderr') do |v|
options[:output] = v || $stdout
# uplot bar -o | foo
# uplot bar -o - -w 30 | foo
options[:output] = v.nil? || v == '-' ? $stdout : v
end
parser.on('-O', '--pass [FILE]', 'file to output input data to [stdout]',
'for inserting YouPlot in the middle of Unix pipes') do |v|
# | uplot bar -O | foo
# | uplot bar -O - -w 30 | foo
options[:pass] = v.nil? || v == '-' ? $stdout : v
end
parser.on('-d', '--delimiter DELIM', String, 'use DELIM instead of [TAB] for field delimiter') do |v|
options[:delimiter] = v