Fry::Shell

Fry::Shell is a flexible shell framework which encourages using loadable libraries of functions.
Download

Fry::Shell Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Gabriel
  • Publisher web site:
  • http://search.cpan.org/~bozo/Fry-Shell-0.15/lib/Fry/Shell.pm

Fry::Shell Tags


Fry::Shell Description

Fry::Shell is a flexible shell framework which encourages using loadable libraries of functions. Fry::Shell is a flexible shell framework which encourages using loadable libraries of functions.SYNOPSIS From the commandline: perl -MFry::Shell -eshell OR In a script: package MyShell; use Fry::Shell; #subs sub evalIt { my $cls = shift; my $code = ($cls->Flag('strict')) ? 'use strict;' : ''; $code .= "@_"; eval "$code"; } sub listStations { my $cls = shift; my @stations = ( {name=>'high energy trance/techno',ip=>'http://64.236.34.196:80/stream/1003'}, {name=>'macondo salsa',ip=>'http://165.132.105.108:8000'}, {name=>'new age',ip=>'http://64.236.34.67:80/stream/2004'}, ); $cls->saveArray(map{$_->{ip}} @stations); return map {$_->{name}} @stations; } #set shell prompt my $prompt = "Clever prompt: "; #initialize shell and load a command and an option my $sh = Fry::Shell->new(prompt=>$prompt, load_obj=>{ cmds=>{listStations=>{a=>'lS'}}, opts=>{strict=>{type=>'flag',a=>'n',default=>0}} } ); #begin shell loop $sh->shell(@ARGV); ####end of example, start of other possible methods #run shell once $sh->once(@ARGV); #loads libraries and runs each library's &_initLib $sh->initLibs(@modules); $sh->loadFile($file); $sh->loadPlugins($myplugin); $sh->runCmd($cmd);Fry::Shell is a simple and flexible way to create a shell. Unlike most other light-weight shells, this module facilitates (un)loading libraries of functions and thus encourages creating shells tailored to several modules. Although the shell is currently only viewable at the commandline, the framework is flexible enough to support other views (especially a web one. This module is mainly serving(will serve) as the model in an MVC framework.From a user perspective it helps to know that a shell session consists of mainly four shell components (whose classes are known as core classes) : libraries (lib), commands (cmd), options (opt) and variables(var). Commands and options are the same as in any shell environment: a command mapping to a function and an option changing the behavior of a command ie changing variables within it or calling functions before the command. Variables store all the configurable data, including data relating to these commands and options. Libraries are containers for a related group of these components. Here are some key features of "Fry::Shell": · Loading/unloading shell components at runtime. · Flexible framework for using shell features via plugins. You can even set up a bare minimum shell needing no external modules! Currently plugins exist for dumping data,readline support,reading shell configurations and viewing shell output. · Commands and options can be aliased for minimal typing at the commandline. · Commands can have help and usage defined. · Commands can have user-defined argument types. One defines argument types by subroutines or tests that they should pass. These tests are then applied to a command's defined argument(s). With defined argument types, one can also define autocompletion routines for a command's arguments. · Options can modify variables. Since variables exist for almost every aspect of the shell, options can change many core shell functions. A handy example is 'parsecmd' which names the current parse subroutine for the current line. Changing this var would change how the input after the options is parsed. · Options can have different behaviors defined including the ability to invoke subroutines when called or to maintain a value for a specified amount of iterations. · Default options include 'menu' which numbers output and allows the next command to reference them by number. · Page output with preferred pager. · Multiline mode. · Comes with a decent default library,Fry::Lib::Default, to dump,list or unload any shell component, run system commands,evaluate perl statements and execute methods of autoloaded libraries. Requirements: · Perl


Fry::Shell Related Software