# $Id$ # package main; use strict; use warnings; use Data::Dumper; my $ret; sub CommandHelp; sub cref_search; sub cref_search_cmd; sub help_Initialize($$) { my %hash = ( Fn => "CommandHelp", Hlp => "[],get help (this screen or module dependent docu)", InternalCmds => "attributes,command,commands,devspec,global,perl" ); $cmds{help} = \%hash; } sub CommandHelp { my ($cl, $arg) = @_; my ($mod,$lang) = split(" ",$arg); $lang //= AttrVal('global','language','en'); $lang = (lc($lang) eq 'de') ? '_DE' : ''; $mod =~ s/\?/help/; if($mod) { my $internals = "attributes,command,commands,devspec,global,perl"; $mod = lc($mod); my $modPath = AttrVal('global','modpath','.'); my $output = ''; if($cmds{help}{InternalCmds} !~ m/$mod\,/) { my %mods; my @modDir = ("$modPath/FHEM"); $mod = $cmds{$mod}{ModuleName} if defined($cmds{$mod}{ModuleName}); foreach my $modDir (@modDir) { eval { 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{lc($l)} = "$modDir/$of"; } } return "Module $mod not found" unless defined($mods{$mod}); # read commandref docu from file $output = cref_search($mods{$mod},$lang); unless($output) { $output = cref_search($mods{$mod},""); $output = "Keine deutsche Hilfe gefunden!
$output" if $output; } $output = "No help found for module: $mod" unless $output; } else { $output = ''; my $i; my $f = "$modPath/docs/commandref_frame$lang.html"; my $skip = 1; my ($err,@text) = FileRead({FileName => $f, ForceType => 'file'}); return $err if $err; foreach my $l (@text) { if($l =~ m/^{TYPE} eq 'telnet' ) { $output =~ s/
/\n/g; $output =~ s//\n/g; $output =~ s///g; $output =~ s/<\/table>//g; $output =~ s///g; $output =~ s/<\/t.>//g; $output =~ s///g; $output =~ s/<\/h.>//g; $output =~ s///g; $output =~ s///g; $output =~ s/