File: synopsis

package info (click to toggle)
libterm-shellui-perl 0.92-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: perl: 1,286; makefile: 2
file content (33 lines) | stat: -rwxr-xr-x 855 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl -w

# Example code from the module's POD to ensure that it actually works.
# Just three simple commands to show argument handling and completion.

# This file is released under the MIT license.

use strict;
use lib '../lib';


use Term::ShellUI;
my $term = new Term::ShellUI(
		commands => {
			"cd" => {
				desc => "Change to directory DIR",
				maxargs => 1, args => sub { shift->complete_onlydirs(@_); },
				proc => sub { chdir($_[0] || $ENV{HOME} || $ENV{LOGDIR}); },
			},
			"pwd" => {
				desc => "Print the current working directory",
				maxargs => 0, proc => sub { system('pwd'); },
			},
			"quit" => {
				desc => "Quit using Fileman", maxargs => 0,
				method => sub { shift->exit_requested(1); },
			}},
		history_file => '~/.shellui-synopsis-history',
	);

print 'Using '.$term->{term}->ReadLine."\n";
$term->run(@ARGV);