mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
98_help.pm: list commands even if not yet loaded
git-svn-id: https://svn.fhem.de/fhem/trunk@13694 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
483505600e
commit
1262f26d08
@ -3,19 +3,21 @@
|
||||
package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
#use Data::Dumper;
|
||||
|
||||
my $ret;
|
||||
|
||||
sub CommandHelp;
|
||||
sub cref_search;
|
||||
sub cref_search_cmd;
|
||||
sub cref_fill_list;
|
||||
|
||||
sub help_Initialize($$) {
|
||||
my %hash = ( Fn => "CommandHelp",
|
||||
Hlp => "[<moduleName>],get help (this screen or module dependent docu)",
|
||||
InternalCmds => "attributes,command,commands,devspec,global,perl" );
|
||||
$cmds{help} = \%hash;
|
||||
cref_fill_list();
|
||||
}
|
||||
|
||||
sub CommandHelp {
|
||||
@ -126,7 +128,7 @@ sub CommandHelp {
|
||||
|
||||
} else { # mod
|
||||
|
||||
cref_search_cmd(undef);
|
||||
# cref_search_cmd(undef);
|
||||
|
||||
my $str = "Possible commands:\n\n" .
|
||||
"Command Parameter\n" .
|
||||
@ -199,6 +201,39 @@ sub cref_search_cmd {
|
||||
return;
|
||||
}
|
||||
|
||||
sub cref_fill_list(){
|
||||
|
||||
my %mods;
|
||||
my %modIdx;
|
||||
my @modDir = ("FHEM");
|
||||
|
||||
foreach my $modDir (@modDir) {
|
||||
opendir(DH, $modDir) || die "Cant open $modDir: $!\n";
|
||||
while(my $l = readdir DH) {
|
||||
next if($l !~ m/^\d\d_.*\.pm$/);
|
||||
my $of = $l;
|
||||
$l =~ s/.pm$//;
|
||||
$l =~ s/^[0-9][0-9]_//;
|
||||
$mods{$l} = "$modDir/$of";
|
||||
$modIdx{$l} = "device";
|
||||
open(MOD, "$modDir/$of") || die("Cant open $modDir/$l");
|
||||
while(my $cl = <MOD>) {
|
||||
if($cl =~ m/^=item\s+(helper|command|device)/) {
|
||||
$modIdx{$l} = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(MOD);
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $mod (sort keys %mods) {
|
||||
my %h = ( Fn => undef,
|
||||
Hlp => "Command $mod not loaded. Use \"help $mod\" for more help" );
|
||||
$cmds{$mod} = \%h if ( ($modIdx{$mod} eq "command") && !(defined($cmds{$mod})) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user