[LDAPsh-cvs] ldapsh ldapsh,1.20,1.20.2.1
Status: Beta
Brought to you by:
rcorvalan
From: <j-d...@us...> - 2003-07-27 07:25:26
|
Update of /cvsroot/ldapsh/ldapsh In directory sc8-pr-cvs1:/tmp/cvs-serv1862 Modified Files: Tag: PATCH-778361 ldapsh Log Message: 1) Added PodHeadings class to extract headings from POD files. 2) Command completion is now available for "which" and "help". 3) "help" without arguments now displays a list of commands. To get all help (the old default), use "help all". Index: ldapsh =================================================================== RCS file: /cvsroot/ldapsh/ldapsh/ldapsh,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -C2 -d -r1.20 -r1.20.2.1 *** ldapsh 27 Jul 2003 07:03:01 -0000 1.20 --- ldapsh 27 Jul 2003 07:25:23 -0000 1.20.2.1 *************** *** 510,513 **** --- 510,544 ---- } + package PodHeadings; + + use strict; + use vars qw(@ISA @EXPORT); + + @ISA = qw(Pod::Select); + + sub verbatim { } + + sub textblock { } + + sub interior_sequence { } + + sub command { + my ($self, $cmd, $text, $line_num, $pod_para) = @_; + ## Just treat this like a textblock + if ($cmd =~ /^head[12]/) { + ## Just treat this like a textblock + my $out_fh = $self->output_handle(); + print $out_fh "\n\n"; + $self->SUPER::textblock($pod_para->raw_text(), $line_num, $pod_para); + } + elsif ($cmd =~ /^head/) { + my $stripped = $pod_para->text(); + my $out_fh = $self->output_handle(); + $stripped =~ s/\s+$//; + print $out_fh $stripped." "; + } + } + + package ldapsh; ############################################################# *************** *** 526,534 **** ### Command completion ### if (substr($line, 0, $start) =~ /^\s*$/) { ! my $oldvalue = $TermAttribs->{completion_word}; ! $TermAttribs->{completion_word} = [_commandListGenerator()]; ! my @ret = $Term->completion_matches($text, $TermAttribs->{'list_completion_function'}); ! $TermAttribs->{completion_word} = $oldvalue; ! return @ret; } --- 557,561 ---- ### Command completion ### if (substr($line, 0, $start) =~ /^\s*$/) { ! return _commandCompletion(@_); } *************** *** 594,603 **** ######################################### ! ### DN Completion ### my $line2 = $line; $line2 =~ s/^\s+//; my ($cmd, $rest) = split(/\s+/, $line2, 2); if ($cmd =~ /^(cd|acd|setdn|pushd|cat|vi|ls|list|dump|ldif|search|cp)$/) { return _cdCommandCompletion(@_); } else { return(); --- 621,634 ---- ######################################### ! ### Parameter Completion ### my $line2 = $line; $line2 =~ s/^\s+//; my ($cmd, $rest) = split(/\s+/, $line2, 2); if ($cmd =~ /^(cd|acd|setdn|pushd|cat|vi|ls|list|dump|ldif|search|cp)$/) { + # DN Completion return _cdCommandCompletion(@_); + } elsif ($cmd =~ /^(help|which)$/) { + # Command Completion + return _commandCompletion(@_); } else { return(); *************** *** 610,613 **** --- 641,653 ---- } + sub _commandCompletion { + my ($text, $line, $start, $end) = @_; + my $oldvalue = $TermAttribs->{completion_word}; + $TermAttribs->{completion_word} = [_commandListGenerator()]; + my @ret = $Term->completion_matches($text, $TermAttribs->{'list_completion_function'}); + $TermAttribs->{completion_word} = $oldvalue; + return @ret; + } + sub _cdCommandCompletion { _bindneeded() or return (); *************** *** 741,747 **** =head3 help ! B<Synopsis>: C<help [E<lt>commandE<gt>]> ! Print some help on the given command (or a global help if no command is given). =cut --- 781,788 ---- =head3 help ! B<Synopsis>: C<help ['E<lt>commandE<gt>'|'all']> ! Display help about the given command (or global help, if 'all' is given). ! If no parameter is given, a summary of commands will be shown. =cut *************** *** 760,764 **** $parser = new Pod::Text::Termcap; } ! if (defined($cmd)) { require Pod::Select; require File::Temp; --- 801,808 ---- $parser = new Pod::Text::Termcap; } ! if (defined($cmd) && $cmd eq "all") { ! $parser->parse_from_file($0, \*STDERR); ! } ! else { require Pod::Select; require File::Temp; *************** *** 769,797 **** push(@docfiles, $Opts->{RCFile}) if (-r $Opts->{RCFile}); foreach my $file (@docfiles) { Pod::Select::podselect( { ! -output => $podfile, ! -sections => [ ! "DESCRIPTION/$cmd\\b.*", ! "COMMANDS/${cmd}\\b.*", ! "COMMANDS/.*/${cmd}" ! ] ! }, ! $file ! ); ! if (-s $podfile) { ! print STDERR "\n------------------------------\n"; ! $parser->parse_from_file($podfile, \*STDERR); ! print STDERR "\n------------------------------\n"; ! $found = 1; ! last; } } if (! $found) { ! print STDERR "No help found on '$cmd'.\n"; } unlink $podfile; - } else { - $parser->parse_from_file($0, \*STDERR); } return 1; --- 813,849 ---- push(@docfiles, $Opts->{RCFile}) if (-r $Opts->{RCFile}); foreach my $file (@docfiles) { + if (defined($cmd)) { Pod::Select::podselect( { ! -output => $podfile, ! -sections => [ ! "DESCRIPTION/$cmd\\b.*", ! "COMMANDS/${cmd}\\b.*", ! "COMMANDS/.*/${cmd}" ! ] ! }, $file); ! } ! else { ! my $headings = new PodHeadings(); ! $headings->select("COMMANDS"); ! $headings->parse_from_file($file, $podfile); ! } ! if (-s $podfile) { ! print STDERR "------------------------------\n"; ! $parser->parse_from_file($podfile, \*STDERR); ! print STDERR "------------------------------\n"; ! $found = 1; ! last; } } if (! $found) { ! if (defined($cmd)) { ! print STDERR "No help found for '$cmd'.\n"; ! } ! else { ! print STDERR "No help found.\n"; ! } } unlink $podfile; } return 1; |