App-hr
view release on metacpan or search on metacpan
NAME
App::hr - Print horizontal bar on the terminal
VERSION
This document describes version 0.268 of App::hr (from Perl distribution
App-hr), released on 2022-09-03.
SYNOPSIS
use App::hr qw(hr hr_r);
hr;
Sample output:
=============================================================================
Set pattern:
hr('x----');
Sample output:
x----x----x----x----x----x----x----x----x----x----x----x----x----x----x----x-
Use random color and random pattern:
hr_r;
You can also use the provided CLI hr.
DESCRIPTION
A demo screencast:
FUNCTIONS
hr([ $pattern [, $color ] ]) => optional STR
Print (under void context) or return (under scalar/array context) a
horizontal ruler with the width of the terminal.
Terminal width is determined using Term::Size.
$pattern is optional, can be multicharacter, but cannot be empty string.
The defautl is "=".
Under Windows, will shave one character at the end because the terminal
cursor will move a line down when printing at the last column.
If $color is set (to a color supported by Term::ANSIColor) *and* colored
output is enabled, output will be colored. Colored output is enabled if:
1) no "NO_COLOR" environment variable is defined; 2) "COLOR" is
undefined or true, or program is run interactively.
hr_r => optional STR
Like "hr", but will set random pattern and random color.
hr_Br => optional STR
Like "hr", but will set random pattern and random color and return a
blinking bar.
hr_app
Usage:
hr_app(%args) -> [$status_code, $reason, $payload, \%result_meta]
Print horizontal bar on the terminal.
hr can be useful as a marker/separator, especially if you use other
commands that might produce a lot of output, and you need to scroll back
lots of pages to see previous output. Example:
% hr; command-that-produces-lots-of-output
============================================================================
Command output
...
...
...
% hr -r; some-command; hr -r; another-command
Usage:
% hr
============================================================================
% hr -c red ;# will output the same bar, but in red
% hr --random-color ;# will output the same bar, but in random color
% hr x----
x----x----x----x----x----x----x----x----x----x----x----x----x----x----x----x
% hr -- -x- ;# specify a pattern that starts with a dash
% hr -p -x- ;# ditto
% hr --random-pattern
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
% hr --random-pattern
*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---
% hr -r ;# shortcut for --random-pattern --random-color
% hr -Br ;# a BLINKING random pattern, random color bar
% hr --help
( run in 1.083 second using v1.01-cache-2.11-cpan-39bf76dae61 )