#!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//$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 after a command for follow-up prompts $advanced Complete each transaction with ${underline}account${off} (i.e. enter your name). END return ACCEPT; }