NAME
OptArgs2::StatusLine - terminal status line
VERSION
2.0.0_5 (2022-09-29)
SYNOPSIS
use OptArgs2::StatusLine '$line', '$prefix';
use Time::HiRes 'sleep'; # just for simulating work
$prefix = '[prog] ';
$line = 'working ... '; sleep .7;
foreach my $i ( 1 .. 10 ) {
$line .= " $i"; sleep .2;
}
# You can localize both $line and $prefix
# If referencing the outer scope $prefix you must
# stringify it with ""
{
local $prefix = "$prefix" . '[debug] ';
local $line = "temporary info"; sleep .8;
}
sleep .7; # back to old value for a while
$line = "Done.\n";
DESCRIPTION
OptArgs2::StatusLine provides a simple terminal status line implementation, using Perl's tie()
mechanism on scalars.
The first argument must be a variable name starting with '$' which is imported into your namespace. Updates or concatenations to that variable get printed immediately.
use OptArgs2::StatusLine '$line';
If the optional second argument is provided it get prefixed to every line of output, which you might like to use with your script's name:
use File::Basename;
use OptArgs2::StatusLine '$line', '['.basename($0).'] ';
If the second argument starts with '$' then it gets imported like $line, allowing you to update the prefix dynamically as shown in the synopsis.
If you would like multiple status lines you can import them all at once:
use OptArgs2::StatusLine
'$line' => '[myprog] ',
'$debug' => '[myprog] (debug) ';
SEE ALSO
SUPPORT & DEVELOPMENT
This distribution is managed via github:
https://github.com/mlawren/p5-OptArgs2/tree/devel
This distribution follows the semantic versioning model:
http://semver.org/
Code is tidied up on Git commit using githook-perltidy:
http://github.com/mlawren/githook-perltidy
AUTHOR
Mark Lawrence <nomad@null.net>
LICENSE
Copyright 2022 Mark Lawrence <nomad@null.net>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.