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
34 my $defh = new IO::File;
35 unless ($defh->open("$main::localcmd/Commands_en.hlp")) {
36 unless($defh->open("$main::cmd/Commands_en.hlp")) {
37 return (1, $self->msg('helpe1'));
42 unless ($lang ne 'en') {
44 unless ($h->open("$main::localcmd/Commands_$lang.hlp")) {
45 unless($h->open("$main::cmd/Commands_$lang.hlp")) {
53 #$line =~ s/[^\w\/]//g;
54 #$line =~ s/\//\.\*\//g;
56 $line =~ s{[^\w/]}{}g;
60 $line = "help" if $line =~ /^\s*$/;
63 my $alias = CmdAlias::get_hlp($line);
64 $line = $alias if $alias;
66 # non english help (if available)
73 last if $state == 2; # come out on next command
75 my ($priv, $cmd, $desc) = split /\^/, $in;
76 next if $priv > $self->priv; # ignore subcommands that are of no concern
77 next unless $cmd =~ /^$line/i;
78 push @out, "$cmd $desc" unless $cmd =~ /-$/o;
89 # return if some help was given, otherwise continue to english help
90 return (1, @out) if @out && $state == 2;
93 # standard 'english' help
95 foreach $in (<$defh>) {
99 last if $state == 2; # come out on next command
101 my ($priv, $cmd, $desc) = split /\^/, $in;
102 next if $priv > $self->priv; # ignore subcommands that are of no concern
103 next unless $cmd =~ /^$line/i;
104 push @out, "$cmd $desc" unless $cmd =~ /-$/o;
115 push @out, $self->msg('helpe2', $line) if @out == 0;