X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fhelp.pl;h=51dfa930a413d56e9e2900b10927dd5068fa602a;hb=a9cff23c7050696bfe1dee906157416c49739f07;hp=781edc3222167d9f80fa490cf79a87a96cbd8375;hpb=171a7a0bf86e9732a33c7829e808129ec01c51c2;p=spider.git diff --git a/cmd/help.pl b/cmd/help.pl index 781edc32..51dfa930 100644 --- a/cmd/help.pl +++ b/cmd/help.pl @@ -2,11 +2,9 @@ # the help subsystem # # It is a very simple system in that you type in 'help ' and it -# looks for a file called .hlp in either the local_cmd directory +# looks for a file called command.hlp in either the local_cmd directory # or the cmd directory (in that order). # -# if you just type in 'help' by itself you get what is in 'help.hlp'. -# # Copyright (c) 1998 - Dirk Koopman G1TLH # # $Id$ @@ -14,18 +12,18 @@ my ($self, $line) = @_; my @out; -my ($path, $fcmd) = ($main::cmd, "help");; -my @out; -my @inpaths = ($main::localcmd, $main::cmd); -my @helpfiles; # this is naff but it will work for now -$line = "help" if !$line; -$fcmd = lc $line; +my $lang = $self->lang; +$lang = 'en' if !$lang; -# each help file starts with a line that looks like:- +# each help file contains lines that looks like:- +# +# === 0^EN^*^Description +# text +# text # -# === 0^EN^HELP^Description +# === 0^EN^help^Description # text # text # text @@ -33,31 +31,49 @@ $fcmd = lc $line; # The fields are:- privilege level, Language, full command name, short description # -if (!open(H, "$path/$fcmd.hlp")) { - return (1, "no help on $line available"); +my $h = new IO::File; + +if (!open($h, "$main::localcmd/Commands_$lang.hlp")) { + $lang = 'en'; + if (!open($h, "$main::cmd/Commands_$lang.hlp")) { + return (1, $self->msg('helpe1')); + } } my $in; -my $include = 0; -my @in = ; -close(H); - -foreach $in (@in) { - next if $in =~ /^\s*\#/; - chomp $in; - if ($in =~ /^===/) { - $include = 0; - $in =~ s/=== //; - my ($priv, $lang, $cmd, $desc) = split /\^/, $in; - next if $priv > $self->priv; # ignore subcommands that are of no concern - next if $self->lang && $self->lang ne $lang; - push @out, "$cmd - $desc"; - $include = 1; - next; - } - push @out, $in if $include; + +$line =~ s/[^\w\/]//g; +$line =~ s/\//\.\*\//g; +$line =~ s/^\s+//g; +$line =~ s/\s+$//g; +$line = "help" if $line =~ /^\s*$/; + +# 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; + } } -push @out, "No help available for $line" if @out == 0; +close($h); + +push @out, $self->msg('helpe2', $line) if @out == 0; return (1, @out);