projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
a nominially working aranea with DX commands converted
[spider.git]
/
cmd
/
apropos.pl
diff --git
a/cmd/apropos.pl
b/cmd/apropos.pl
index d3def0cd5dffe9230122ff759d0e68fc22377a55..98f799b360ecc2e55f4c770eb3debbb490599719 100644
(file)
--- a/
cmd/apropos.pl
+++ b/
cmd/apropos.pl
@@
-1,4
+1,3
@@
-#
# the help subsystem
#
# apropos - this does a grep on the command file and returns the commands
# the help subsystem
#
# apropos - this does a grep on the command file and returns the commands
@@
-15,11
+14,14
@@
my @out;
my $lang = $self->lang;
$lang = 'en' if !$lang;
my $lang = $self->lang;
$lang = 'en' if !$lang;
+#print "$line\n";
my $in;
$line = 'help' unless $line;
my $in;
$line = 'help' unless $line;
+$line =~ s/\ball\b/.*/;
$line =~ s/\W//g; # remove dubious characters
$line =~ s/\W//g; # remove dubious characters
+print "$line\n";
-my ($priv, $cmd, $desc);
+my ($priv, $cmd, $
param, $
desc);
my %cmd;
my $defh = new IO::File;
my %cmd;
my $defh = new IO::File;
@@
-40,25
+42,22
@@
if ($lang ne 'en') {
}
# do english help
}
# do english help
-my $include;
foreach $in (<$defh>) {
next if $in =~ /^\#/;
chomp $in;
$in =~ s/\r$//;
if ($in =~ /^===/) {
foreach $in (<$defh>) {
next if $in =~ /^\#/;
chomp $in;
$in =~ s/\r$//;
if ($in =~ /^===/) {
-
$cmd{$cmd} = "$cmd $desc" if $include
;
-
$include = 0
;
- $
in =~ s/=== //
;
-
($priv, $cmd, $desc) = split /\^/, $in
;
+
# print "$in\n"
;
+
($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)}
;
+ $
param ||= ''
;
+
$desc ||= ''
;
next if $priv > $self->priv; # ignore subcommands that are of no concern
next if $priv > $self->priv; # ignore subcommands that are of no concern
- next unless $
cmd =~ /$line/i || $desc
=~ /$line/i;
+ next unless $
in
=~ /$line/i;
next if $cmd =~ /-$/o;
next if $cmd =~ /-$/o;
-
$include = 1
;
+
push @{$cmd{$cmd}->{en}}, "$cmd$param $desc"
;
next;
}
next;
}
- $include =~ 1 if $cmd =~ /$line/i;
}
}
-$cmd{$cmd} = "$cmd $desc" if $include;
$defh->close;
# override with any not english help
$defh->close;
# override with any not english help
@@
-69,23
+68,28
@@
if ($h) {
chomp $in;
$in =~ s/\r$//;
if ($in =~ /^===/) {
chomp $in;
$in =~ s/\r$//;
if ($in =~ /^===/) {
-
$cmd{$cmd} = "$cmd $desc" if $include
;
-
$include = 0
;
- $
in =~ s/=== //
;
-
($priv, $cmd, $desc) = split /\^/, $in
;
+
# print "$in\n"
;
+
($priv, $cmd, $param, $desc) = $in =~ m{^===\s+(\d)\^(\S+)(\s+[^\^]+)?\^(.*)}
;
+ $
param ||= ''
;
+
$desc ||= ''
;
next if $priv > $self->priv; # ignore subcommands that are of no concern
next if $priv > $self->priv; # ignore subcommands that are of no concern
- next unless $
cmd =~ /$line/i || $desc
=~ /$line/i;
+ next unless $
in
=~ /$line/i;
next if $cmd =~ /-$/o;
next if $cmd =~ /-$/o;
-
$include = 1
;
+
push @{$cmd{$cmd}->{$lang}}, "$cmd$param $desc"
;
next;
}
next;
}
- $include =~ 1 if $cmd =~ /$line/i;
}
}
- $cmd{$cmd} = "$cmd $desc" if $include;
$h->close;
}
$h->close;
}
-push @out, map {$cmd{$_}} sort keys %cmd;
+foreach my $k (sort keys %cmd) {
+ my $v;
+ if ($v = $cmd{$k}->{$lang}) {
+ push @out, @$v;
+ } elsif ($v = $cmd{$k}->{en}) {
+ push @out, @$v;
+ }
+}
push @out, $self->msg('helpe2', $line) if @out == 0;
push @out, $self->msg('helpe2', $line) if @out == 0;