From cf7a62fe2c58fd64896cbad779ec35ae85318468 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 17 Dec 2021 23:17:54 +0100 Subject: [PATCH] =?UTF-8?q?TT#156156=20Switch=20to=20=C2=AB-=C2=BB=20as=20?= =?UTF-8?q?the=20word=20separator=20in=20CLI=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- helper/compare_dbs.pl | 48 ++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/helper/compare_dbs.pl b/helper/compare_dbs.pl index 882f996..7cd47ed 100755 --- a/helper/compare_dbs.pl +++ b/helper/compare_dbs.pl @@ -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 [] + +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= List of schemes which should be compared. + --user-db1= User of the 1st schema + --pass-db1= Password of the 1st schema + --user-db2= User of the 2nd schema + --pass-db2= Password of the 2nd schema. + -h, --help Print this message and exit. __USAGE__ ; print $usage;