From dfc027d972b24b33356a2efa2879bfcc5668b502 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Mon, 7 Jun 2021 23:51:46 +0900 Subject: [PATCH] Accept hyphens as an output option --- lib/youplot/parser.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/youplot/parser.rb b/lib/youplot/parser.rb index d8691e4..05c56e7 100644 --- a/lib/youplot/parser.rb +++ b/lib/youplot/parser.rb @@ -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