/usr/share/doc/libterm-shellui-perl/examples/synopsis-big is in libterm-shellui-perl 0.92-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #!/usr/bin/perl -w
# This was originally the example code from Term::ShellUI's documentation
# but it grew too big. Now it's intended to demonstrate most of the
# available features and still be easy to read.
# This file is released under the MIT license.
use strict;
use lib '../lib';
use Term::ShellUI;
my $term = new Term::ShellUI(
commands => get_commands(),
history_file => '~/.shellui-synopsis-history',
);
$term->add_eof_exit_hook(sub {print "Type 'quit' to quit.\n"; return 1;});
print 'Using '.$term->{term}->ReadLine."\n";
$term->run(@ARGV);
sub get_commands
{
return {
"h" => { alias => "help", exclude_from_completion => 1 },
"?" => { alias => "help", exclude_from_completion =>1 },
"help" => {
desc => "Print helpful information",
args => sub { shift->help_args(undef, @_); },
method => sub { shift->help_call(undef, @_); }
},
"history" => { desc => "Prints the command history",
doc => "Specify a number to list the last N lines of history\n" .
"Pass -c to clear the command history, " .
"-d NUM to delete a single item\n",
args => "[-c] [-d] [number]",
method => sub { shift->history_call(@_) },
exclude_from_history => 1,
},
"exit" => {
desc => "Exits the program.",
maxargs => 0,
method => sub { shift->exit_requested(1); },
},
"exists" => {
desc => "Shows whether files exist",
args => sub { shift->complete_files(@_); },
proc => sub {
print "exists: " .
join(", ", map {-e($_) ? "<$_>":$_} @_) .
"\n";
},
doc => <<EOL,
Comprehensive documentation for our the exists command.
Pass any number of filenames. If a file exists, it is
printed in <angle brackets>.
This detailed doc can\nspan\nmany\nlines
EOL
},
"show" => {
desc => "An example of using subcommands",
cmds => {
"warranty" => { proc => "You have no warranty!\n" },
"args" => {
args => [ sub {['create', 'delete']},
\&Term::ShellUI::complete_files ],
desc => "Print the passed arguments",
method => sub {
my $self = shift;
my $parms = shift;
print $self->get_cname($parms->{cname}) .
": " . join(" ",@_), "\n";
},
},
},
},
"quit" => {
desc => "Quit using Fileman",
maxargs => 0,
method => sub { shift->exit_requested(1); },
},
# Term::ShellUI normally displays "asdf: unknown command".
# This shows how to use the default command. If the user
# types an unknown command, ShellUI calls '' if it exists.
'' => {
proc => "No command here by that name!\n",
desc => "No help for unknown commands.",
doc => "Well, here's a little help: don't type them.\n",
},
};
}
|