pbot-vm: `vm-exec -lang=?` once again lists languages without needing <code> argument

This commit is contained in:
Pragmatic Software 2022-02-18 12:45:28 -08:00
parent a7b27098ca
commit 8b5428f77b
1 changed files with 7 additions and 5 deletions

View File

@ -109,7 +109,7 @@ sub make_context_from_args(@args_in) {
}
# parse options specific to vm-exec
while ($context->{code} =~ s/^-(lang|vm-cid|vm-vport|vm-serial|vm)=([^ ]+)\s+//) {
while ($context->{code} =~ s/^-(lang|vm-cid|vm-vport|vm-serial|vm)=([^ ]+)\s*//) {
my ($option, $value) = ($1, $2);
print STDERR "Overriding `$option` to `$value`.\n";
$context->{$option} = lc $value;
@ -195,7 +195,6 @@ sub configure_context($context, $config) {
# override values
$context->{'vm-serial'} = $entry->{'serial'};
$context->{'vm-heart'} = $entry->{'heart'};
$context->{'vm-cid'} = $entry->{'cid'};
$context->{'vm-vport'} = $entry->{'vport'};
} else {
@ -213,7 +212,6 @@ sub configure_context($context, $config) {
# update any undefined values, preserving any existing values
$context->{'vm-serial'} //= $entry->{'serial'};
$context->{'vm-heart'} //= $entry->{'heart'};
$context->{'vm-cid'} //= $entry->{'cid'};
$context->{'vm-vport'} //= $entry->{'vport'};
}
@ -234,6 +232,11 @@ sub main() {
configure_context($context, $config);
# load language before checking usage in order to handle -lang=? flag
# to list languages instea of showing a usage message
my $lang = load_language($context);
# now check usage
if (not length $context->{code}) {
if (exists $context->{usage}) {
print "$context->{usage}\n";
@ -243,8 +246,7 @@ sub main() {
exit 1;
}
my $lang = load_language($context);
# run the language
$lang->process_interactive_edit;
$lang->process_standard_options;
$lang->process_custom_options;