2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

help.pm: minor improvements

git-svn-id: https://svn.fhem.de/fhem/trunk@18337 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2019-01-19 14:52:06 +00:00
parent 106d569288
commit 2bdf8005c1

View File

@ -37,26 +37,26 @@ sub CommandHelp {
$mod = lc($mod); $mod = lc($mod);
my $modPath = AttrVal('global','modpath','.'); my $modPath = AttrVal('global','modpath','.');
my $output = ''; my $output = '';
my $outputInfo = cref_findInfo($modPath,$mod); my $outputInfo = cref_findInfo($modPath,$mod);
if($cmds{help}{InternalCmds} !~ m/$mod\,/) { if($cmds{help}{InternalCmds} !~ m/$mod\,/) {
my %mods; my %mods;
my @modDir = ("$modPath/FHEM"); my @modDir = ("$modPath/FHEM");
$mod = $cmds{$mod}{ModuleName} if defined($cmds{$mod}) && defined($cmds{$mod}{ModuleName}); $mod = $cmds{$mod}{ModuleName} if defined($cmds{$mod}) && defined($cmds{$mod}{ModuleName});
foreach my $modDir (@modDir) { foreach my $modDir (@modDir) {
eval { opendir(DH, $modDir); }; # || die "Cant open $modDir: $!\n"; eval { opendir(DH, $modDir); }; # || die "Cant open $modDir: $!\n";
while(my $l = readdir DH) { while(my $l = readdir DH) {
next if($l !~ m/^\d\d_.*\.pm$/); next if($l !~ m/^\d\d_.*\.pm$/);
my $of = $l; my $of = $l;
$l =~ s/.pm$//; $l =~ s/.pm$//;
$l =~ s/^[0-9][0-9]_//; $l =~ s/^[0-9][0-9]_//;
$mods{lc($l)} = "$modDir/$of"; $mods{lc($l)} = "$modDir/$of";
} }
} }
return "Module $mod not found" unless defined($mods{$mod}); return "Module $mod not found" unless defined($mods{$mod});
@ -73,13 +73,13 @@ sub CommandHelp {
} else { } else {
$output = "<br/><b>Internal command:</b> $mod"; $output = "<br/><b>Internal command:</b> $mod";
my $i; my $i;
my $f = "$modPath/docs/commandref_frame$lang.html"; my $f = "$modPath/docs/commandref_frame$lang.html";
my $skip = 1; my $skip = 1;
my ($err,@text) = FileRead({FileName => $f, ForceType => 'file'}); my ($err,@text) = FileRead({FileName => $f, ForceType => 'file'});
return $err if $err; return $err if $err;
foreach my $l (@text) { foreach my $l (@text) {
if($l =~ m/^<a name=\"$mod\"/) { if($l =~ m/^<a name=\"$mod\"/) {
$skip = 0; $skip = 0;
} elsif($l =~ m/^<!-- $mod.end/) { } elsif($l =~ m/^<!-- $mod.end/) {
@ -87,9 +87,9 @@ sub CommandHelp {
} elsif (!$skip) { } elsif (!$skip) {
$output .= $l; $output .= $l;
} }
} }
} }
if( $cl && $cl->{TYPE} eq 'telnet' ) { # telnet output if( $cl && $cl->{TYPE} eq 'telnet' ) { # telnet output
$output =~ s/<br\s*\?>/\n/ig; $output =~ s/<br\s*\?>/\n/ig;
@ -134,9 +134,9 @@ sub CommandHelp {
# cref_search_cmd(undef); # cref_search_cmd(undef);
my $str = "Possible commands:\n\n" . my $str = "Possible commands:\n\n" .
"Command Parameter\n" . "Command Parameter\n" .
" Description\n" . " Description\n" .
"----------------------------------------------------------------------\n"; "----------------------------------------------------------------------\n";
for my $cmd (sort keys %cmds) { for my $cmd (sort keys %cmds) {
next if($cmd =~ m/header:command/); next if($cmd =~ m/header:command/);
@ -179,7 +179,7 @@ sub cref_search {
return $err if $err; return $err if $err;
foreach my $l (@text) { foreach my $l (@text) {
if($l =~ m/^=begin html$lang$/) { if($l =~ m/^=begin html$lang$/) {
$skip = 0; $skip = 0;
} elsif($l =~ m/^=end html$lang$/) { } elsif($l =~ m/^=end html$lang$/) {
$skip = 1; $skip = 1;
} elsif(!$skip) { } elsif(!$skip) {
@ -205,7 +205,7 @@ sub cref_search_cmd {
return $err if $err; return $err if $err;
foreach my $l (@text) { foreach my $l (@text) {
if($l =~ m/<b>Fhem commands<\/b>/) { if($l =~ m/<b>Fhem commands<\/b>/) {
$skip = 0; $skip = 0;
} elsif($l =~ m/<\/ul>/) { } elsif($l =~ m/<\/ul>/) {
$skip = 1; $skip = 1;
} elsif(!$skip && $l !~ m/<ul>/) { } elsif(!$skip && $l !~ m/<ul>/) {
@ -254,7 +254,7 @@ sub cref_fill_list(){
foreach my $mod (sort keys %mods) { foreach my $mod (sort keys %mods) {
my %h = ( Fn => undef, my %h = ( Fn => undef,
Hlp => "Command $mod not loaded. Use \"help $mod\" for more help" ); Hlp => "Command $mod not loaded. Use \"help $mod\" for more help" );
$cmds{$mod} = \%h if ( ($modIdx{$mod} eq "command") && !(defined($cmds{$mod})) ); $cmds{$mod} = \%h if ( ($modIdx{$mod} eq "command") && !(defined($cmds{$mod})) );
} }
} }
@ -264,8 +264,8 @@ sub cref_findInfo {
my ($l,@line,$found,$text); my ($l,@line,$found,$text);
my ($err,@text) = FileRead({FileName => "$modPath/MAINTAINER.txt", ForceType => 'file'}); my ($err,@text) = FileRead({FileName => "$modPath/MAINTAINER.txt", ForceType => 'file'});
foreach $l (@text) { foreach $l (@text) {
@line = split("[ \t][ \t]*", $l,3); @line = split(" ", $l,3);
$found = ($l =~ m/_$mod/i); $found = ($l =~ m/^([0-9][0-9])_$mod\.pm$/i);
last if ($found); last if ($found);
} }
if($found) { if($found) {