TT#156156 Switch to «-» as the word separator in CLI options

The prevalent convention in the project is to use «-» instead of «_» to
split words in options. Switch the options to that, and keep backwards
compatibility option alias that emits a deprecation warning while people
transition to the new names. The alias will be removed on the next LTS.

Clarify --help output.

Change-Id: Ic25ba7a152ce11c3be5106dc58d481add7ca02a8
mr10.3
Guillem Jover 5 years ago
parent 3352cb0fb8
commit cf7a62fe2c

@ -197,35 +197,45 @@ else {
exit $exit;
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$argv->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub get_options {
GetOptions(
'formatter=s' => \$argv->{'formatter'},
'schemes=s' => \$argv->{'schemes'},
'user_db1=s' => \$argv->{'user_db1'},
'pass_db1=s' => \$argv->{'pass_db1'},
'user_db2=s' => \$argv->{'user_db2'},
'pass_db2=s' => \$argv->{'pass_db2'},
'user_db1=s' => \&old_option,
'user-db1=s' => \$argv->{'user_db1'},
'pass_db1=s' => \&old_option,
'pass-db1=s' => \$argv->{'pass_db1'},
'user_db2=s' => \&old_option,
'user-db2=s' => \$argv->{'user_db2'},
'pass_db2=s' => \&old_option,
'pass-db2=s' => \$argv->{'pass_db2'},
'help|h' => sub{ print_usage(); exit(0); },
);
}
sub print_usage {
my $usage =<<__USAGE__
This script compares two databases by structure and prints result.
compare_db.pl [options]
OPTIONS
--formatter=[tap] The format of output.
Supported values:
tap - print in a TAP format.
--schemes List of schemes which should be compared.
--user_db1 User of the 1st schema
--pass_db1 Password of the 1st schema
--connect_db2 DSN of the 2nd schema
--user_db2 User of the 2nd schema
--pass_db2 Password of the 2nd schema
--help, -h Print this message and exit
Usage: compare_db.pl [<options>]
This script compares two databases by structure and prints result.
Options:
--formatter=[tap] The format of output. Supported values:
tap - print in a TAP format.
--schemes=<name> List of schemes which should be compared.
--user-db1=<username> User of the 1st schema
--pass-db1=<password> Password of the 1st schema
--user-db2=<username> User of the 2nd schema
--pass-db2=<password> Password of the 2nd schema.
-h, --help Print this message and exit.
__USAGE__
;
print $usage;

Loading…
Cancel
Save