From: Mischa POSLAWSKY Date: Thu, 3 Oct 2019 21:51:57 +0000 (+0200) Subject: numeric inline parameters override value input X-Git-Tag: v1.07~25 X-Git-Url: http://git.shiar.net/barcat.git/commitdiff_plain/4896a612b1c772c53350ef1ec612861f613343dc numeric inline parameters override value input Commandline shorthand for simple manual entry with unambiguous numbers. --- diff --git a/barcat b/barcat index 9cfe3e3..fc4cb3c 100755 --- a/barcat +++ b/barcat @@ -112,6 +112,7 @@ $opt{'value-length'} = 1 if $opt{unmodified}; $opt{'signal-stat'} //= exists $SIG{INFO} ? 'INFO' : 'QUIT'; $opt{markers} //= '=avg >31.73v <68.27v +50v |0'; $opt{palette} //= $opt{color} && [31, 90, 32]; +$opt{input} = @ARGV && $ARGV[0] =~ m/\A[-0-9]/ ? \@ARGV : undef; my (@lines, @values, @order); @@ -133,7 +134,7 @@ if (defined $opt{interval}) { } my $valmatch = qr/$opt{anchor} ( \h* -? [0-9]* \.? [0-9]+ (?: e[+-]?[0-9]+ )? |)/x; -while (readline) { +while (defined ($_ = $opt{input} ? shift @{ $opt{input} } : readline)) { s/\r?\n\z//; s/^\h*// unless $opt{unmodified}; push @values, s/$valmatch/\n/ && $1; @@ -305,11 +306,12 @@ barcat - graph to visualize input values =head1 SYNOPSIS -B [] [] +B [] [... | ] =head1 DESCRIPTION -Visualizes relative sizes of values read from input (file(s) or STDIN). +Visualizes relative sizes of values read from input +(parameters, file(s) or STDIN). Contents are concatenated similar to I, but numbers are reformatted and a bar graph is appended to each line. diff --git a/t/t0101-value_parameters_--_1_4_8_2_6_3_9_5_2.out b/t/t0101-value_parameters_--_1_4_8_2_6_3_9_5_2.out new file mode 100644 index 0000000..e844d75 --- /dev/null +++ b/t/t0101-value_parameters_--_1_4_8_2_6_3_9_5_2.out @@ -0,0 +1,9 @@ +1 ---- +4 -----------<---+- +8 -----------<---+-=---->----------- +2 -------- +6 -----------<---+-=---->-- +3 -----------<- +9 -----------<---+-=---->--------------- +5 -----------<---+-=--- +2 --------