App-Cleo
view release on metacpan or search on metacpan
lib/App/Cleo.pm view on Meta::CPAN
our $VERSION = 0.004;
#-----------------------------------------------------------------------------
sub new {
my $class = shift;
my $self = {
shell => $ENV{SHELL} || '/bin/bash',
prompt => colored( ['green'], '(%d)$ '),
delay => 25_000,
@_,
};
return bless $self, $class;
}
#-----------------------------------------------------------------------------
sub run {
lib/App/Cleo.pm view on Meta::CPAN
CMD:
for (my $i = 0; $i < @commands; $i++) {
my $cmd = $commands[$i];
chomp $cmd;
$self->do_cmd($cmd) and next CMD
if $cmd =~ s/^!!!//;
print sprintf $self->{prompt}, $i;
my @steps = split /%%%/, $cmd;
while (my $step = shift @steps) {
my $key = ReadKey(0);
print "\n" if $key =~ m/[srp]/;
last CMD if $key eq 'q';
next CMD if $key eq 's';
redo CMD if $key eq 'r';
lib/App/Cleo.pm view on Meta::CPAN
The constructor accepts arguments as key-value pairs. The following keys are
supported:
=over 4
=item delay
Number of milliseconds to wait before displaying each character of the command.
The default is C<25_000>.
=item prompt
String to use for the artificial prompt. The token C<%d> will be substituted
with the number of the current command. The default is C<(%d)$>.
=item shell
Path to the shell command that will be used to run the commands. Defaults to
either the C<SHELL> environment variable or C</bin/bash>.
=back
=head1 METHODS
( run in 1.959 second using v1.01-cache-2.11-cpan-6aa56a78535 )