EB::Shell::Base

EB::Shell::Base is a generic class to build line-oriented command interpreters.
Download

EB::Shell::Base Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Darren Chamberlain
  • Publisher web site:
  • http://search.cpan.org/~darren/Tie-Google-0.03/Google.pm

EB::Shell::Base Tags


EB::Shell::Base Description

EB::Shell::Base is a generic class to build line-oriented command interpreters. EB::Shell::Base is a generic class to build line-oriented command interpreters.SYNOPSIS package My::Shell; use base qw(EB::Shell::Base); sub do_greeting { return "Hello!" }EB::Shell::Base is a slightly modified version of Shell::Base. It is modifed for the EekBoek program http://www.squirrel.nl/eekboek and NOT intended for general use. Please use Shell::Base instead.Shell::Base is a base class designed for building command line programs. It defines a number of useful defaults, simplifies adding commands and help, and integrates well with Term::ReadLine.After writing several REP (Read-Eval-Print) loops in Perl, I found myself wishing for something a little more convenient than starting with: while(1) { my $line = ; last unless defined $line; chomp $line; if ($line =~ /^...FeaturesShell::Base provides simple access to many of the things I always write into my REP's, as well as support for many thing that I always intend to, but never find time for:readline supportShell::Base provides simple access to the readline library via Term::ReadLine, including built-in tab-completion and easy integration with the history file features.If a subclass does want or need Term::ReadLine support, then it can be replaced in subclasses by overriding a few methods. See "Using Shell::Base Without readline", below.Trivial to add commandsAdding commands to your shell is as simple as creating methods: the command foo is dispatched to do_foo. In addition, there are hooks for unknown commands and for when the user just hits , both of which a subclass can override.Integrated help systemShell::Base makes it simple to integrate online help within alongside your command methods. Help for a command foo can be retrieved with help foo, with the addition of one method. In addition, a general help command lists all possible help commands; this list is generated at run time, so there's no possibility of forgetting to add help methods to the list of available topics.Pager integrationOutput can be sent through the user's default pager (as defined by $ENV{'PAGER'}, with a reasonable default) or dumped directly to STDOUT.Customizable output stream(s)Printing is handled through a print() method, which can be overridden in a subclass to send output anywhere.Pre- and post-processing methodsInput received from readline() can be processed before it is parsed, and output from command methods can be post-processed before it is sent to print().Automatic support for RC filesA simple RC-file parser is built in, which handles name = value type configuration files. This parser handles comments, whitespace, multiline definitions, boolean and (name, value) option types, and multiple files (e.g., /etc/foorc, $HOME/.foorc).Shell::Base was originally based, conceptually, on Python's cmd.Cmd class, though it has expanded far beyond what Cmd offers. Requirements: · Perl


EB::Shell::Base Related Software