X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=blobdiff_plain;f=cmd%2Fhelp.pl;h=781edc3222167d9f80fa490cf79a87a96cbd8375;hp=60eef05943eb133654f0b802583c2b613bee3405;hb=171a7a0bf86e9732a33c7829e808129ec01c51c2;hpb=0824a94355e5fb2b4c379bb013d66466725629f5 diff --git a/cmd/help.pl b/cmd/help.pl index 60eef059..781edc32 100644 --- a/cmd/help.pl +++ b/cmd/help.pl @@ -14,6 +14,50 @@ 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; + +# each help file starts with a line that looks like:- +# +# === 0^EN^HELP^Description +# text +# text +# text +# +# 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 $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; +} +push @out, "No help available for $line" if @out == 0; +return (1, @out);