Last active
March 10, 2021 14:04
-
-
Save ElectricCoffee/37961eafa01bb3eccfc9bfbf6c1bda95 to your computer and use it in GitHub Desktop.
woman, a unified manual printing tool. Prints the help page of a program if a manpage doesn't exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# woman | |
# copyright 2021 Nikolaj Lepka <[email protected]> | |
use v5.30; | |
use warnings; | |
use autodie; | |
use Pod::Usage; | |
use Getopt::Long; | |
GetOptions ( | |
help => \my $wanthelp, | |
); | |
if ($wanthelp) { | |
pod2usage( -verbose => 2, -noperldoc => 1 ); | |
} elsif (!@ARGV) { | |
pod2usage( -verbose => 1); | |
} | |
my $command = shift; | |
my @options = ( | |
"man $command", | |
"$command --help | less", | |
"$command -help | less", | |
"$command -h | less", | |
"$command -? | less" | |
); | |
for my $option (@options) { | |
my $rc = system $option; | |
if ($rc != 0) { | |
next; | |
} else { | |
exit; | |
} | |
} | |
say "Nothing worked. Sure this program even has a help page?"; | |
__END__ | |
=head1 NAME | |
Woman, provides docs where man doesn't. | |
=head1 SYNOPSIS | |
woman [--help] <PROGNAME> | |
=head1 OPTIONS | |
=over 12 | |
=item --help | |
Prints extended help message. | |
=item PROGNAME | |
The program name you wish to run. Examples include C<ls>, C<man>, C<rustup> | |
=back | |
=head1 DESCRIPTION | |
A simple script with the purpose of addressing some of C<man>'s shortcomings. | |
Not every program has an available manpage, and far too often I'm greeted with B<No manual entry for foo>. | |
Woman seeks to remedy this by simply piping the help page of a program into C<less> if a manpage doesn't exist. | |
=head1 LICENCE | |
Copyright (c) 2020, Nikolaj Lepka <[email protected]> | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
1. Redistributions of source code must retain the above copyright notice, this | |
list of conditions and the following disclaimer. | |
2. Redistributions in binary form must reproduce the above copyright notice, | |
this list of conditions and the following disclaimer in the documentation | |
and/or other materials provided with the distribution. | |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
=head1 AUTHOR | |
Nikolaj Lepka - L<https://wausoft.eu> | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment