Checkpoint -- if there's only one option, don't bother to prompt for
it. This commit was SVN r3659.
Этот коммит содержится в:
родитель
9de44317db
Коммит
e85f80594c
@ -122,24 +122,33 @@ sub do_menu {
|
|||||||
my $i;
|
my $i;
|
||||||
my $level = $options;
|
my $level = $options;
|
||||||
my @config;
|
my @config;
|
||||||
|
|
||||||
for ($i = 0; $i <= $#$prompts; ++$i) {
|
for ($i = 0; $i <= $#$prompts; ++$i) {
|
||||||
while (1) {
|
while (1) {
|
||||||
my @keys = sort keys (%$level);
|
my @keys = sort keys (%$level);
|
||||||
for (my $j = 0; $j <= $#keys; ++$j) {
|
|
||||||
printf("%d. %s\n", $j + 1, $keys[$j]);
|
|
||||||
}
|
|
||||||
print "\n$$prompts[$i] (1-" . ($#keys + 1) . "): ";
|
|
||||||
|
|
||||||
my $input = <STDIN>;
|
if ($#keys == 0) {
|
||||||
print "\n";
|
print "Assuming: $$prompts[$i] = $keys[0]\n\n";
|
||||||
chomp($input);
|
push(@config, $keys[0]);
|
||||||
if ($input < 1 || $input > $#keys + 1) {
|
$level = $level->{$keys[0]};
|
||||||
print "Please enter a valid selection\n";
|
} else {
|
||||||
next;
|
for (my $j = 0; $j <= $#keys; ++$j) {
|
||||||
|
printf("%d. %s\n", $j + 1, $keys[$j]);
|
||||||
|
}
|
||||||
|
print "\n$$prompts[$i] (1-" . ($#keys + 1) . "): ";
|
||||||
|
|
||||||
|
my $input = <STDIN>;
|
||||||
|
print "\n";
|
||||||
|
chomp($input);
|
||||||
|
if ($input < 1 || $input > $#keys + 1) {
|
||||||
|
print "Please enter a valid selection\n";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
push(@config, $keys[$input - 1]);
|
||||||
|
$level = $level->{$keys[$input - 1]};
|
||||||
}
|
}
|
||||||
|
|
||||||
push(@config, $keys[$input - 1]);
|
|
||||||
$level = $level->{$keys[$input - 1]};
|
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +324,7 @@ my $url = "$base_url/$submit_uri?$result";
|
|||||||
my $req = HTTP::Request->new(POST => $url);
|
my $req = HTTP::Request->new(POST => $url);
|
||||||
my $res = $ua->request($req);
|
my $res = $ua->request($req);
|
||||||
if ($res->is_success()) {
|
if ($res->is_success()) {
|
||||||
# print "Response: " . $res->content . "\n";
|
print "Response: " . $res->content . "\n";
|
||||||
print "Results submitted successfully. Thanks!\n";
|
print "Results submitted successfully. Thanks!\n";
|
||||||
} else {
|
} else {
|
||||||
die $res->message;
|
die $res->message;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user