Something like this?

whacl> <tab><tab>
dig          help         llocks       need_commit  rcs          unlock
exit         list         lock         perform      touch_lm     untouch_lm

whacl> help rcs
Usage: rcs <rtr>

whacl> rcs rtrA
rcs(rtrA)> <tab><tab>
exit        help        lock        publish     syncronize  unlock

rcs(rtrA)> exit 
whacl> help lock
Usage: lock <rtr> <acl>

whacl> lock rtrA external-blocks
acl(rtrA,external-blocks)> <tab><tab>
block            help             list             unlock_and_exit

acl(rtrA,external-blocks)> block 192.168.254.1/32
block(192.168.254.1/32)> <tab><tab>
case     end      freshen  insert   mac      note     priv     status
delete   exit     help     list     modify   options  show     update

block(192.168.254.1/32)> delete
block(192.168.254.1/32)> exit 
acl(rtrA,external-blocks)> unlock_and_exit 
whacl> exit 

This goes something like:

use Q::Shell; use Q::RCSShell; use Q::ACLShell; use Q::WhaclShell; Q::WhaclShell->new ( prompt => 'whacl> ' )->loop(); exit 0; ##### use Q::Shell; package Q::WhaclShell; our (@ISA) = qw( Q::Shell ); sub new { my ($class,%param) = @_; # blah blah SUPER::new $self->add_dispatch( rcs => [ \&_rcs, "short help", "long help" ], lock => [ \&_lock, "short help", "long help" ], # ... ); return $self; } sub _rcs { my ($self,@arg) = @_; Q::RCSShell->new( )->loop(@arg); } sub _lock { my ($self,@arg) = @_; Q::ACLShell->new( )->loop(@arg); } 1; # and so on for Q::RCSShell and Q::ACLShell package Q::Shell; my %default_commands = ( help => [ \&_help, "short help", "long help" ], exit => [ \&_exit, "short help", "long help" ], ); sub add_dispatch { } sub del_dispatch { } sub _cmd_list { keys %{$_[0]->{_dispatch}} } sub _help { # help - show all short help # help <cmd> - show long help for <cmd> } sub _exit { $_[0]->{done} = 1 } sub new { # setup ReadLine # copy default_commands to $self->{_dispatch} return $self; } sub dispatch { # find and do <cmd> or warn whatever } sub loop { # setup ReadLine with completions from $self->_cmd_list while ( not $self->{done} ) { # read and dispatch <cmd> <args> # reset ReadLine stuff (a command may have changed them) } } 1;

In reply to Re: Tab completion in a shell by zengargoyle
in thread Tab completion in a shell by hotshot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.