7 |
|
|
8 |
my $sh = Term::Shelly->new(); |
my $sh = Term::Shelly->new(); |
9 |
|
|
10 |
|
if (0) { |
11 |
$sh->out( |
$sh->out( |
12 |
"This is a demo of Term::Shelly. It is designed to show you some of the |
"This is a demo of Term::Shelly. It is designed to show you some of the |
13 |
features of it. For this demo there is only a short number of features |
features of it. For this demo there is only a short number of features |
20 |
" . join(" ", @WORDS)." |
" . join(" ", @WORDS)." |
21 |
Commands must start with a / (forward slash) and be at the beginning of |
Commands must start with a / (forward slash) and be at the beginning of |
22 |
the line."); |
the line."); |
23 |
|
} |
24 |
|
|
25 |
$sh->{"completion_function"} = \&completer; |
$sh->{"completion_function"} = \&completer; |
26 |
|
$sh->prompt("Foo> "); |
27 |
|
|
28 |
|
$sh->out("Welcome!"); |
29 |
|
|
30 |
while (1) { |
while (1) { |
31 |
$sh->do_one_loop(); |
$sh->do_one_loop(); |
45 |
$word = substr($curword,1); |
$word = substr($curword,1); |
46 |
@matches = map { "/$_" } grep(m/^\Q$word\E/i, @COMMANDS); |
@matches = map { "/$_" } grep(m/^\Q$word\E/i, @COMMANDS); |
47 |
} else { |
} else { |
48 |
@matches = grep(m/\Q$curword\E/i, @WORDS); |
@matches = grep(m/^\Q$curword\E/i, @WORDS); |
49 |
} |
} |
50 |
|
|
51 |
return @matches; |
return @matches; |