diff options
| -rwxr-xr-x | greypool | 48 |
1 files changed, 45 insertions, 3 deletions
@@ -108,7 +108,6 @@ sub parse_opts { $email = shift @ARGV; fatal "extra junk on the command line after '$email'" if @ARGV; - $color_output = -t STDOUT unless defined $color_output; $privdir = $ENV{HOME} . "/.greypool" unless defined $privdir; $config_file = $privdir . "/config"; $css_file = $privdir . "/style.css"; @@ -336,6 +335,19 @@ sub parse_mask { $masked{$pkg} = \@versions if @versions; } +sub parse_color { + for($_[0]) { + /^[y1t]/i && do { $config_color = 1; return; }; + /^[n0f]/i && do { $config_color = 0; return; }; + /^a/i && do { $config_color = undef; return; }; + fatal "$config_file:$.: color must be 'yes', 'no', or 'auto'."; + } +} + +sub parse_pager { + $pager = $_[0]; +} + sub find_config_file { my $file = shift; if($file =~ m,^/,) { @@ -359,7 +371,7 @@ sub read_config_file { s/\s+$//; # trim trailing whitespace (my $key, $val) = split /\s+/, $_, 2; - fatal "$config_file line $. malformed (no spaces)" unless defined $val; + fatal "$file line $. malformed (no spaces)" unless defined $val; for(lc $key) { my $ok; @@ -370,9 +382,11 @@ sub read_config_file { /mask/ && do { $ok++; parse_mask($val); }; /transform/ && do { $ok++; parse_transform($val) }; /include/ && do { - $ok++; read_config_file(find_config_file($val)); + next; }; + /color/ && do { $ok++; parse_color($val); }; + /pager/ && do { $ok++; parse_pager($val); }; fatal "$config_file line $. malformed (unknown key '$_')" unless $ok; } } @@ -402,6 +416,17 @@ sub apply_config { $cachedir = $privdir . "/cache/$email"; $cachestampfile = $cachedir . "/stamp"; + if(defined($config_color)) { + $color_output = $config_color unless defined $color_output; + } else { + $color_output = -t STDOUT; + } + + if(defined($pager) && -t STDOUT) { + open $outfh, "|$pager" or fatal "can't execute pager"; + select $outfh; + } + print_config_summary() if $verbose > 1; } @@ -995,6 +1020,23 @@ packages you've updated recently, but the updates haven't been picked up by reology yet. The filename can be a full path (used as-is), or else it will be treated as relative to the config directory. +=item B<color> I<yes> | I<no> | I<auto> + +Whether to colorize output. Default is I<auto>, meaning yes if +standard output is a terminal, otherwise no. + +This sets the default, but you can still use the B<-c> / B<--color> +or B<-m> / B<--mono> options to override. + +=item B<pager> I<command> + +If this is set, and standard output is a terminal, and the B<-h> / +B<--html> option was not used, output will be piped to I<command>. +There is no default for this. + +If you want colorized output in the pager, try B<color yes> and +B<pager less -MR>. + =back =head1 NOTES |
