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;
63 $line = "help" if $line =~ /^\s*$/;
66 my $alias = CmdAlias::get_hlp($line);
67 $line = $alias if $alias;
69 # non english help (if available)
76 last if $state == 2; # come out on next command
78 my ($priv, $cmd, $desc) = split /\^/, $in;
79 next if $priv > $self->priv; # ignore subcommands that are of no concern
80 next unless $cmd =~ /^$line/i;
81 push @out, "$cmd $desc" unless $cmd =~ /-$/o;
92 # return if some help was given, otherwise continue to english help
93 return (1, @out) if @out && $state == 2;
96 # standard 'english' help
98 foreach $in (<$defh>) {
102 last if $state == 2; # come out on next command
104 my ($priv, $cmd, $desc) = split /\^/, $in;
105 next if $priv > $self->priv; # ignore subcommands that are of no concern
106 next unless $cmd =~ /^$line/i;
107 push @out, "$cmd $desc" unless $cmd =~ /-$/o;
118 push @out, $self->msg('helpe2', $line) if @out == 0;