X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fhelp.pl;h=d87de98113d6fc84829dd08619cedbd592dc307e;hb=7de34899527cbc4dfacdcc6452926b3d2d73792c;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=20b0104deaeab77fa7ab1444dbcedfcdbf5865f8;p=spider.git diff --git a/cmd/help.pl b/cmd/help.pl index e69de29b..d87de981 100644 --- a/cmd/help.pl +++ b/cmd/help.pl @@ -0,0 +1,78 @@ +# +# the help subsystem +# +# It is a very simple system in that you type in 'help ' and it +# looks for a file called command.hlp in either the local_cmd directory +# or the cmd directory (in that order). +# +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# + +my ($self, $line) = @_; +my @out; + +# this is naff but it will work for now +$line = "help" unless $line; +my $lang = $self->lang; +$lang = 'en' if !$lang; + +# each help file contains lines that looks like:- +# +# === 0^EN^*^Description +# text +# text +# +# === 0^EN^help^Description +# text +# text +# text +# +# The fields are:- privilege level, Language, full command name, short description +# + +my $h = new IO::File; + +if (!open($h, "$main::localcmd/Commands_$lang.hlp")) { + if (!open($h, "$main::cmd/Commands_$lang.hlp")) { + return (1, $self->msg('helpe1')); + } +} +my $in; + +$line =~ s/![\w\/]//og; +$line =~ s/\//\.\*\//og; +$line =~ s/^\s+//og; +$line =~ s/\s+$//og; + +# sort out aliases +my $alias = CmdAlias::get_hlp($line); +$line = $alias if $alias; + +my $state = 0; +foreach $in (<$h>) { + next if $in =~ /^\#/; + chomp $in; + if ($in =~ /^===/) { + last if $state == 2; # come out on next command + $in =~ s/=== //; + my ($priv, $cmd, $desc) = split /\^/, $in; + next if $priv > $self->priv; # ignore subcommands that are of no concern + next unless $cmd =~ /^$line/i; + push @out, "$cmd $desc" unless $cmd =~ /-$/o; + $state = 1; + next; + } + if ($state > 0) { + push @out, " $in"; + $state = 2; + } +} + +close($h); + +push @out, $self->msg('helpe2', $line) if @out == 0; + +return (1, @out); +