The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Term::Shell::Pluggable - Pluggable command-line framework

VERSION

Version 0.04

SYNOPSIS

There is Term::Shell module in the first place. This is hybrid of that one with Module::Pluggable. So you could add command line hooks to your big and scary multi-module perl application.

#!/usr/bin/env perl
package Example;

use warnings;
use strict;

use Getopt::Long qw(GetOptionsFromArray);

sub smry_bubble { 'bubblesort numbers' }
sub run_bubble {
    my $class = shift;
    Getopt::Long::GetOptionsFromArray(\@_,
        'verbose' => \my $verbose,
    ) and @_ or die "wrong options or numbers are missing\n" . $class->help_bubble;
    my @numbers = @_;
    ...
}
sub help_bubble { <<HELP
usage: bubble [-v] <number1> <number2> ...
HELP
}

package main;

use Term::Shell::Pluggable;
Term::Shell::Pluggable->run(packages => [
    'Example',
    'Some::Other::Example' # another package i.e. defined in separate .pm file 
]);

SEE ALSO

Term::Shell

COPYRIGHT

Copyright 2013 Dmitri Popov.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.