47 lines
1.2 KiB
Perl
47 lines
1.2 KiB
Perl
#!perl
|
|
|
|
HELP1 "help2" => "Advanced usage instructions";
|
|
|
|
use List::Util qw(max);
|
|
|
|
my $bold = "\e[1m";
|
|
my $underline = "\e[4m";
|
|
my $off = "\e[0m";
|
|
|
|
sub command :Tab(help,help2,wtf,omgwtfbbq) ($self, $cart, $command, @) {
|
|
return NEXT if $command !~ /^(?:help2?|wtf|omgwtfbbq)$/;
|
|
|
|
my $help2 = $command =~ /help2/;
|
|
my $hash = $help2 ? \%::HELP : \%::HELP1;
|
|
|
|
say "\n${bold}Valid commands:${off}";
|
|
|
|
my $width = max(map length s/[<>]//rg, keys %$hash);
|
|
|
|
for my $command (sort keys %$hash) {
|
|
my $display = $command;
|
|
|
|
my $length = length $display =~ s/[<>]//rg;
|
|
|
|
$display =~ s/</$underline/g;
|
|
$display =~ s/>/$off/g;
|
|
|
|
# Because of markup codes, a simple %-42s doesn't work.
|
|
$display .= " " x ($width - $length);
|
|
|
|
say sprintf " %s %s", $display, $hash->{$command};
|
|
}
|
|
|
|
my $advanced = $help2
|
|
? "${bold}Advanced usage:${off} pass space separated arguments to parameters"
|
|
: ""; # Line intentionally left blank
|
|
|
|
print <<"END";
|
|
|
|
${bold}Simple usage: ${off} press <Enter> after a command for follow-up prompts
|
|
$advanced
|
|
Complete each transaction with ${underline}account${off} (i.e. enter your name).
|
|
END
|
|
|
|
return ACCEPT;
|
|
}
|