[tpm] Implementing a 'less' like pager in perl
Shaun Fryer
sfryer at sourcery.ca
Mon Mar 1 19:16:23 PST 2010
The hackish way to do it would be to simply call the pager for them...
my $pager = $ENV{PAGER} || 'most' || 'less' || 'more';
if ($argv0_is_help) {
if ( the_pager_exists_on_their_system($pager) ) {
system "perl $0 --helpless | $pager";
} else {
print help() and exit;
}
}
if ($argv0_is_helpless) {
print help();
}
Or something like that... You could probably write something up in
curses, but (apart from legitimate security issue) ... why reinvent
the wheel?
--
Shaun Fryer
On Mon, Mar 1, 2010 at 9:58 PM, James E Keenan <jkeen at verizon.net> wrote:
>
> On Mar 1, 2010, at 8:49 PM, Digimer wrote:
>
>> Hi all,
>>
>> I like to have built-in '--help' messages in some of my programs, but am
>> always at a loss for how to allow the user to page through it. Usually I
>> have a message at the bottom akin to; "Please call './foo --help |less' to
>> make reading this help message easier".
>
> ...
>
>>
>> I know I could use perldoc, but I don't like assuming that my user knows
>> anything about perl.
>>
>
> If you "usually" tell the user to call './foo -- help | less', then it
> stands to reason your user is familiar with the Unix command-line.
>
> In which case, instructing them to call 'perldoc ./foo' is not much of a
> stretch.
>
> Or, you could create 'man' pages for your programs. They, too,
> automatically include paging.
>
> If you wrote POD for your programs, you could use 'pod2man' to generate the
> man pages. (And I have a CPAN distribution, Pod-Multi, that will let you
> generate documentation from POD simultaneously to text, man and HTML
> format.)
>
> Jim Keenan
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
More information about the toronto-pm
mailing list