OptArgs2::StatusLine - terminal status line
2.0.0_4 (2022-09-28)
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";
OptArgs2::StatusLine provides a simple terminal status line implementation, using Perl's tie() mechanism on scalars.
tie()
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) ';
OptArgs2
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
Mark Lawrence <nomad@null.net>
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.
To install OptArgs2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OptArgs2
CPAN shell
perl -MCPAN -e shell install OptArgs2
For more information on module installation, please visit the detailed CPAN module installation guide.