4 # It is a very simple system in that you type in 'help <cmd>' and it
5 # looks for a file called command.hlp in either the local_cmd directory
6 # or the cmd directory (in that order).
8 # Copyright (c) 1998 - Dirk Koopman G1TLH
13 my ($self, $line) = @_;
16 # this is naff but it will work for now
17 my $lang = $self->lang;
18 $lang = 'en' if !$lang;
20 # each help file contains lines that looks like:-
26 # === 0^help^Description
31 # The fields are:- privilege level, full command name, short description
37 my $defh = new IO::File;
38 unless ($defh->open("$main::localcmd/Commands_en.hlp")) {
39 unless($defh->open("$main::cmd/Commands_en.hlp")) {
40 return (1, $self->msg('helpe1'));
47 unless ($h->open("$main::localcmd/Commands_$lang.hlp")) {
48 unless($h->open("$main::cmd/Commands_$lang.hlp")) {
56 #$line =~ s/[^\w\/]//g;
57 #$line =~ s/\//\.\*\//g;
59 $line =~ s{[^\w/]}{}g;
62 $line =~ s/[\s\r]+$//g;
63 $line = "help" if $line =~ /^\s*$/;
66 my $alias = CmdAlias::get_hlp($line);
67 $line = $alias if $alias;
69 # non english help (if available)
77 last if $state == 2; # come out on next command
79 my ($priv, $cmd, $desc) = split /\^/, $in;
80 next if $priv > $self->priv; # ignore subcommands that are of no concern
81 next unless $cmd =~ /^$line/i;
82 push @out, "$cmd $desc" unless $cmd =~ /-$/o;
93 # return if some help was given, otherwise continue to english help
94 return (1, @out) if @out && $state == 2;
97 # standard 'english' help
99 foreach $in (<$defh>) {
100 next if $in =~ /^\#/;
103 last if $state == 2; # come out on next command
105 my ($priv, $cmd, $desc) = split /\^/, $in;
106 next if $priv > $self->priv; # ignore subcommands that are of no concern
107 next unless $cmd =~ /^$line/i;
108 push @out, "$cmd $desc" unless $cmd =~ /-$/o;
119 push @out, $self->msg('helpe2', $line) if @out == 0;