From d0e9787ea8e709d8cbd91e87e363812e669c0ca6 Mon Sep 17 00:00:00 2001 From: minima Date: Mon, 17 Sep 2001 11:34:34 +0000 Subject: [PATCH] 1. Fixed help and apropos commands so that they default to english if the language is not english and help in the 'not english' language isn't available. 2. added some help text for sh/newc. --- Changes | 5 ++++ cmd/Aliases | 1 + cmd/Commands_en.hlp | 15 ++++++++++ cmd/apropos.pl | 59 ++++++++++++++++++++++++++++++-------- cmd/help.pl | 70 ++++++++++++++++++++++++++++++++++----------- 5 files changed, 122 insertions(+), 28 deletions(-) diff --git a/Changes b/Changes index 344b0574..da9e2a88 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,8 @@ +17Sep01======================================================================= +1. Fixed help and apropos commands so that they default to english if +the language is not english and help in the 'not english' language isn't +available. +2. added some help text for sh/newc. 15Sep01======================================================================= 1. released 1.48 2. found 1st bug, fixed unset/logininfo reseting itself after logout diff --git a/cmd/Aliases b/cmd/Aliases index fb6fd20a..57e524f4 100644 --- a/cmd/Aliases +++ b/cmd/Aliases @@ -107,6 +107,7 @@ package CmdAlias; '^sh\w*/dx/(\d+)-(\d+)', 'show/dx $1-$2', 'show/dx', '^sh\w*/dx/(\d+)', 'show/dx $1', 'show/dx', '^sh\w*/dx/d(\d+)', 'show/dx from $1', 'show/dx', + '^sh\w*/newc/n', 'show/newconfiguration node', 'show/newconfiguration', '^sh\w*/tnc', 'who', 'who', '^sh\w*/up', 'show/cluster', 'show/cluster', '^sh\w*/w\w*/(\d+)-(\d+)', 'show/wwv $1-$2', 'show/wwv', diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 10a4805c..095b7764 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -1580,6 +1580,21 @@ Gives you an estimate of the long path propagation characterics. It should be noted that the figures will probably not be very useful, nor terrible accurate, but it is included for completeness. +=== 0^SHOW/NEWCONFIGURATION []^Show all the nodes and users visible +This command allows you to see all the users that can be seen +and the nodes to which they are connected. + +This command produces essentially the same information as +SHOW/CONFIGURATION except that it shows all the duplication of +any routes that might be present It also uses a different format +which may not take up quite as much space if you don't have any +loops. + +BE WARNED: the list that is returned can be VERY long + +=== 0^SHOW/NEWCONFIGURATION/NODE^Show all the nodes connected locally +Show all the nodes connected to this node in the new format. + === 1^SHOW/NODE [ ...]^Show the type and version number of nodes Show the type and version (if connected) of the nodes specified on the command line. If no callsigns are specified then a sorted list of all diff --git a/cmd/apropos.pl b/cmd/apropos.pl index 1226a0a7..8e4d4eb2 100644 --- a/cmd/apropos.pl +++ b/cmd/apropos.pl @@ -15,26 +15,37 @@ my @out; my $lang = $self->lang; $lang = 'en' if !$lang; -my $h = new IO::File; +my $in; +$line = 'help' unless $line; +$line =~ s/\W//g; # remove dubious characters + +my ($priv, $cmd, $desc); +my %cmd; -if (!open($h, "$main::localcmd/Commands_$lang.hlp")) { - if (!open($h, "$main::cmd/Commands_$lang.hlp")) { +my $defh = new IO::File; +unless ($defh->open("$main::localcmd/Commands_en.hlp")) { + unless($defh->open("$main::cmd/Commands_en.hlp")) { return (1, $self->msg('helpe1')); } } -my $in; -$line = 'help' unless $line; -$line =~ s/\W//og; # remove dubious characters +my $h; +unless ($lang ne 'en') { + $h = new IO::File; + unless ($h->open("$main::localcmd/Commands_$lang.hlp")) { + unless($h->open("$main::cmd/Commands_$lang.hlp")) { + undef $h; + } + } +} +# do english help my $include; -my ($priv, $cmd, $desc); - -foreach $in (<$h>) { +foreach $in (<$defh>) { next if $in =~ /^\#/; chomp $in; if ($in =~ /^===/) { - push @out, "$cmd $desc" if $include; + $cmd{$cmd} = "$cmd $desc" if $include; $include = 0; $in =~ s/=== //; ($priv, $cmd, $desc) = split /\^/, $in; @@ -46,9 +57,33 @@ foreach $in (<$h>) { } $include =~ 1 if $cmd =~ /$line/i; } -push @out, "$cmd $desc" if $include; +$cmd{$cmd} = "$cmd $desc" if $include; +$defh->close; + +# override with any not english help +if ($h) { + my $include; + foreach $in (<$h>) { + next if $in =~ /^\#/; + chomp $in; + if ($in =~ /^===/) { + $cmd{$cmd} = "$cmd $desc" if $include; + $include = 0; + $in =~ s/=== //; + ($priv, $cmd, $desc) = split /\^/, $in; + next if $priv > $self->priv; # ignore subcommands that are of no concern + next unless $cmd =~ /$line/i || $desc =~ /$line/i; + next if $cmd =~ /-$/o; + $include = 1; + next; + } + $include =~ 1 if $cmd =~ /$line/i; + } + $cmd{$cmd} = "$cmd $desc" if $include; + $h->close; +} -close($h); +push @out, map {$cmd{$_}} sort keys %cmd; push @out, $self->msg('helpe2', $line) if @out == 0; diff --git a/cmd/help.pl b/cmd/help.pl index 51dfa930..b44457b8 100644 --- a/cmd/help.pl +++ b/cmd/help.pl @@ -19,30 +19,42 @@ $lang = 'en' if !$lang; # each help file contains lines that looks like:- # -# === 0^EN^*^Description +# === 0^*^Description # text # text # -# === 0^EN^help^Description +# === 0^help^Description # text # text # text # -# The fields are:- privilege level, Language, full command name, short description +# The fields are:- privilege level, full command name, short description # -my $h = new IO::File; - -if (!open($h, "$main::localcmd/Commands_$lang.hlp")) { - $lang = 'en'; - if (!open($h, "$main::cmd/Commands_$lang.hlp")) { +my $defh = new IO::File; +unless ($defh->open("$main::localcmd/Commands_en.hlp")) { + unless($defh->open("$main::cmd/Commands_en.hlp")) { return (1, $self->msg('helpe1')); } } + +my $h; +unless ($lang ne 'en') { + $h = new IO::File; + unless ($h->open("$main::localcmd/Commands_$lang.hlp")) { + unless($h->open("$main::cmd/Commands_$lang.hlp")) { + undef $h; + } + } +} + my $in; -$line =~ s/[^\w\/]//g; -$line =~ s/\//\.\*\//g; +#$line =~ s/[^\w\/]//g; +#$line =~ s/\//\.\*\//g; + +$line =~ s{[^\w/]}{}g; +$line =~ s{/}{.*/}g; $line =~ s/^\s+//g; $line =~ s/\s+$//g; $line = "help" if $line =~ /^\s*$/; @@ -51,12 +63,40 @@ $line = "help" if $line =~ /^\s*$/; my $alias = CmdAlias::get_hlp($line); $line = $alias if $alias; +# non english help (if available) +if ($h) { + my $state = 0; + foreach $in (<$h>) { + next if $in =~ /^\#/; + chomp $in; + if ($in =~ /^===/) { + last if $state == 2; # come out on next command + $in =~ s/=== //; + my ($priv, $cmd, $desc) = split /\^/, $in; + next if $priv > $self->priv; # ignore subcommands that are of no concern + next unless $cmd =~ /^$line/i; + push @out, "$cmd $desc" unless $cmd =~ /-$/o; + $state = 1; + next; + } + if ($state > 0) { + push @out, " $in"; + $state = 2; + } + } + $h->close; + + # return if some help was given, otherwise continue to english help + return (1, @out) if @out && $state == 2; +} + +# standard 'english' help my $state = 0; -foreach $in (<$h>) { +foreach $in (<$defh>) { next if $in =~ /^\#/; chomp $in; if ($in =~ /^===/) { - last if $state == 2; # come out on next command + last if $state == 2; # come out on next command $in =~ s/=== //; my ($priv, $cmd, $desc) = split /\^/, $in; next if $priv > $self->priv; # ignore subcommands that are of no concern @@ -66,14 +106,12 @@ foreach $in (<$h>) { next; } if ($state > 0) { - push @out, " $in"; + push @out, " $in"; $state = 2; } } - -close($h); +$defh->close; push @out, $self->msg('helpe2', $line) if @out == 0; - return (1, @out); -- 2.43.0