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.

Change-Id: I5dd702f68cbc548a027ba57a5bff1716944cf159
mr10.3
Guillem Jover 3 years ago
parent 0d9f089f93
commit d037f0855f

@ -15,22 +15,46 @@ my $opts = {
verbose => 0,
};
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$opts->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub parse_option {
my ($name, $value) = @_;
$name =~ tr/-/_/;
$opts->{$name} = $value;
}
GetOptions($opts,
'help|h' => sub { usage() },
'op=s',
'login=s',
'password=s',
'email=s',
'reseller_id=i',
'is_system=i',
'is_master=i',
'is_superuser=i',
'is_ccare=i',
'read_only=i',
'show_paswords=i',
'call_data=i',
'billing_data=i',
'lawful_intercept=i',
'reseller_id=i' => \&old_option,
'reseller-id=i' => \&parse_option,
'is_system=i' => \&old_option,
'is-system=i' => \&parse_option,
'is_master=i' => \&old_option,
'is-master=i' => \&parse_option,
'is_superuser=i' => \&old_option,
'is-superuser=i' => \&parse_option,
'is_ccare=i' => \&old_option,
'is-ccare=i' => \&parse_option,
'read_only=i' => \&old_option,
'read-only=i' => \&parse_option,
'show_paswords=i' => \&old_option,
'show-paswords=i' => \&parse_option,
'call_data=i' => \&old_option,
'call-data=i' => \&parse_option,
'billing_data=i' => \&old_option,
'billing-data=i' => \&parse_option,
'lawful_intercept=i' => \&old_option,
'lawful-intercept=i' => \&parse_option,
'verbose',
) or usage();
@ -149,7 +173,7 @@ Operation: "list", "add", "update", "delete"
=over 8
=item B<--login>, B<login>
=item B<--login> B<login>
Administrator login name
@ -157,45 +181,45 @@ Administrator login name
Password field
=item B<--password> I<password>
=item B<--email> I<email>
Email field
=item B<--reseller_id>
=item B<--reseller-id>
Reseller id the administartor belongs to (used in "add" and "update").
=item B<--is_system> I<0|1>
=item B<--is-system> I<0|1>
A flag that defines wether the user is the system root and can manage everything.
*Only administrators with this flag are able to manage "lawful intercept" administrators.
=item B<--is_superuser> I<0|1>
=item B<--is-superuser> I<0|1>
A flag that defines wether the administrator can manage all resellers on the platform.
=item B<--is_master> I<0|1>
=item B<--is-master> I<0|1>
A flag that defines wether the administrator can manage other administrators within the same reseller.
=item B<--is_ccare> I<0|1>
=item B<--is-ccare> I<0|1>
A flag that defines wether the administrator is limited only to manage Customers and Subscribers.
(coped with <is_superuser> defines wether the scope is limited to only Reseller the administrator belongs to or across all Resellers)
=item B<--read_only> I<0|1>
=item B<--read-only> I<0|1>
Engages "Read Only" functionality for the administrator.
=item B<--show_passwords> I<0|1>
=item B<--show-passwords> I<0|1>
Show clear text passwords to the administrator.
=item B<--call_data> I<0|1>
=item B<--call-data> I<0|1>
The administrator is able to access call traces ("voisniff" must be also enabled).
=item B<--billing_data> I<0|1>
=item B<--billing-data> I<0|1>
Enables the administrator to apply "Balance top up" and "Vouchers".

@ -17,10 +17,26 @@ my $opts = {
verbose => 0,
};
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$opts->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub parse_option {
my ($name, $value) = @_;
$name =~ tr/-/_/;
$opts->{$name} = $value;
}
GetOptions($opts,
'help|h' => sub { usage() },
'billing_profile_id=i',
'contact_id=i',
'billing_profile_id=i' => \&old_option,
'billing-profile-id=i' => \&parse_option,
'contact_id=i' => \&old_option,
'contact-id=i' => \&parse_option,
'type=s',
'verbose',
) or usage();
@ -84,11 +100,11 @@ B<This program> creates a customer on the NGCP platform.
=over 8
=item B<--billing_profile_id>
=item B<--billing-profile-id> I<id>
Billing profile id.
=item B<--contact_id>
=item B<--contact-id> I<id>
Contact id.
@ -98,7 +114,7 @@ Contact id.
=over 8
=item B<--type>
=item B<--type> I<customer-type>
Customer can be one of the "sipaccount" or "pbxaccount" type. Defaults to
"sipaccount".

@ -18,12 +18,29 @@ my $opts = {
verbose => 0,
};
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$opts->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub parse_option {
my ($name, $value) = @_;
$name =~ tr/-/_/;
$opts->{$name} = $value;
}
GetOptions($opts,
'help|h' => sub { usage() },
'domain=s',
'reseller_id=i',
'skip_xmpp',
'skip_sip',
'reseller_id=i' => \&old_option,
'reseller-id=i' => \&parse_option,
'skip_xmpp' => \&old_option,
'skip-xmpp' => \&parse_option,
'skip_sip' => \&old_option,
'skip-sip' => \&parse_option,
'verbose',
) or usage();
@ -103,16 +120,16 @@ The domain to create.
=over 8
=item B<--reseller_id> I<rid>
=item B<--reseller-id> I<rid>
Reseller id. Default 1.
=item B<--skip_sip>
=item B<--skip-sip>
Skip reloading SIP services. If true, changes will not be effective immedeately
until the respective service is restarted or properly notified. Default false.
=item B<--skip_xmpp>
=item B<--skip-xmpp>
Skip reloading XMPP services. If true, changes will not be effective immedeately
until the respective service is restarted or properly notified. Default false.

@ -17,9 +17,24 @@ my $opts = {
pbx_pilot => 0,
};
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$opts->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub parse_option {
my ($name, $value) = @_;
$name =~ tr/-/_/;
$opts->{$name} = $value;
}
GetOptions($opts,
'help|h' => sub { usage() },
'customer_id=i',
'customer_id=i' => \&old_option,
'customer-id=i' => \&parse_option,
'username|u=s',
'password|p=s',
'domain|d=s',
@ -28,10 +43,13 @@ GetOptions($opts,
'ac|a=s',
'sn|n=s',
'aliases=s@',
'display_name=s',
'display_name=s' => \&old_option,
'display-name=s' => \&parse_option,
'webpassword|w=s',
'pbx_pilot',
'pbx_extension=s',
'pbx_pilot' => \&old_option,
'pbx-pilot' => \&parse_option,
'pbx_extension=s' => \&old_option,
'pbx-extension=s' => \&parse_option,
'verbose',
) or usage();
@ -127,7 +145,7 @@ B<This program> creates a subscriber on the NGCP platform.
=over 8
=item B<--customer_id> I<cid>
=item B<--customer-id> I<cid>
An existing customer id to assign this subscriber to.
@ -176,7 +194,7 @@ A local number part of the subscriber's number.
Set the administrative flag for the new subscriber.
Defaults to 0 (no).
=item B<--display> I<display-name>
=item B<--display-name> I<display-name>
A display name part of the subscriber's number.
@ -190,12 +208,12 @@ A list of alias numbers
devid_alias=Alice
=item B<--pbx_pilot>
=item B<--pbx-pilot>
Set the "pbx pilot" flag for the new subscriber.
Defaults to 0 (no).
=item B<--pbx_extension>
=item B<--pbx-extension>
PBX extension number (only usable for PBX subscribers)

@ -18,11 +18,27 @@ my $opts = {
verbose => 0,
};
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$opts->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub parse_option {
my ($name, $value) = @_;
$name =~ tr/-/_/;
$opts->{$name} = $value;
}
GetOptions($opts,
'help|h' => sub { usage() },
'domain=s',
'skip_xmpp',
'skip_sip',
'skip_xmpp' => \&old_option,
'skip-xmpp' => \&parse_option,
'skip_sip' => \&old_option,
'skip-sip' => \&parse_option,
'verbose',
) or usage();
@ -110,12 +126,12 @@ The domain name to delete.
=over 8
=item B<--skip_sip>
=item B<--skip-sip>
Skip reloading SIP services. If true, changes will not be effective immedeately
until the respective service is restarted or properly notified. Default false.
=item B<--skip_xmpp>
=item B<--skip-xmpp>
Skip reloading XMPP services. If true, changes will not be effective immedeately
until the respective service is restarted or properly notified. Default false.

@ -15,9 +15,24 @@ my $opts = {
verbose => 0,
};
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$opts->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub parse_option {
my ($name, $value) = @_;
$name =~ tr/-/_/;
$opts->{$name} = $value;
}
GetOptions($opts,
'help|h' => sub { usage() },
'customer_id=i',
'customer_id=i' => \&old_option,
'customer-id=i' => \&parse_option,
'verbose',
) or usage();
@ -79,7 +94,7 @@ B<This program> retreives a customer from the NGCP platform.
=over 8
=item B<--customer_id> I<cid>
=item B<--customer-id> I<cid>
Customer id.

@ -15,9 +15,24 @@ my $opts = {
verbose => 0,
};
# XXX: Remove after mr10.5.
sub old_option {
my ($name, $value) = @_;
my $newname = $name =~ tr/_/-/r;
$opts->{$name} = $value;
warn "$0: option --$name is deprecated; use --$newname instead\n";
}
sub parse_option {
my ($name, $value) = @_;
$name =~ tr/-/_/;
$opts->{$name} = $value;
}
GetOptions($opts,
'help|h' => sub { usage() },
'customer_id=i',
'customer_id=i' => \&old_option,
'customer-id=i' => \&parse_option,
'verbose',
) or usage();
@ -84,7 +99,7 @@ B<This program> terminates a customer on the NGCP platform.
=over 8
=item B<--customer_id> I<cid>
=item B<--customer-id> I<cid>
Customer ID.

Loading…
Cancel
Save