3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 07:19:23 +01:00

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

View File

@ -109,7 +109,7 @@ sub make_context_from_args(@args_in) {
} }
# parse options specific to vm-exec # 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); my ($option, $value) = ($1, $2);
print STDERR "Overriding `$option` to `$value`.\n"; print STDERR "Overriding `$option` to `$value`.\n";
$context->{$option} = lc $value; $context->{$option} = lc $value;
@ -195,7 +195,6 @@ sub configure_context($context, $config) {
# override values # override values
$context->{'vm-serial'} = $entry->{'serial'}; $context->{'vm-serial'} = $entry->{'serial'};
$context->{'vm-heart'} = $entry->{'heart'};
$context->{'vm-cid'} = $entry->{'cid'}; $context->{'vm-cid'} = $entry->{'cid'};
$context->{'vm-vport'} = $entry->{'vport'}; $context->{'vm-vport'} = $entry->{'vport'};
} else { } else {
@ -213,7 +212,6 @@ sub configure_context($context, $config) {
# update any undefined values, preserving any existing values # update any undefined values, preserving any existing values
$context->{'vm-serial'} //= $entry->{'serial'}; $context->{'vm-serial'} //= $entry->{'serial'};
$context->{'vm-heart'} //= $entry->{'heart'};
$context->{'vm-cid'} //= $entry->{'cid'}; $context->{'vm-cid'} //= $entry->{'cid'};
$context->{'vm-vport'} //= $entry->{'vport'}; $context->{'vm-vport'} //= $entry->{'vport'};
} }
@ -234,6 +232,11 @@ sub main() {
configure_context($context, $config); 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 (not length $context->{code}) {
if (exists $context->{usage}) { if (exists $context->{usage}) {
print "$context->{usage}\n"; print "$context->{usage}\n";
@ -243,8 +246,7 @@ sub main() {
exit 1; exit 1;
} }
my $lang = load_language($context); # run the language
$lang->process_interactive_edit; $lang->process_interactive_edit;
$lang->process_standard_options; $lang->process_standard_options;
$lang->process_custom_options; $lang->process_custom_options;