From d037f0855f46aedffe206f42fef74320cbe82dc1 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 17 Dec 2021 23:39:43 +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. Change-Id: I5dd702f68cbc548a027ba57a5bff1716944cf159 --- bin/ngcp-api-admins | 66 +++++++++++++++++++++++++------------ bin/ngcp-create-customer | 26 ++++++++++++--- bin/ngcp-create-domain | 29 ++++++++++++---- bin/ngcp-create-subscriber | 34 ++++++++++++++----- bin/ngcp-delete-domain | 24 +++++++++++--- bin/ngcp-get-customer | 19 +++++++++-- bin/ngcp-terminate-customer | 19 +++++++++-- 7 files changed, 169 insertions(+), 48 deletions(-) diff --git a/bin/ngcp-api-admins b/bin/ngcp-api-admins index b7cb23b..ce41867 100755 --- a/bin/ngcp-api-admins +++ b/bin/ngcp-api-admins @@ -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 +=item B<--login> B Administrator login name @@ -157,45 +181,45 @@ Administrator login name Password field -=item B<--password> I +=item B<--email> I 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 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". diff --git a/bin/ngcp-create-customer b/bin/ngcp-create-customer index 4d9631d..e3a2000 100755 --- a/bin/ngcp-create-customer +++ b/bin/ngcp-create-customer @@ -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 creates a customer on the NGCP platform. =over 8 -=item B<--billing_profile_id> +=item B<--billing-profile-id> I Billing profile id. -=item B<--contact_id> +=item B<--contact-id> I Contact id. @@ -98,7 +114,7 @@ Contact id. =over 8 -=item B<--type> +=item B<--type> I Customer can be one of the "sipaccount" or "pbxaccount" type. Defaults to "sipaccount". diff --git a/bin/ngcp-create-domain b/bin/ngcp-create-domain index 7d5dcee..e055647 100755 --- a/bin/ngcp-create-domain +++ b/bin/ngcp-create-domain @@ -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 +=item B<--reseller-id> I 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. diff --git a/bin/ngcp-create-subscriber b/bin/ngcp-create-subscriber index 8f85da1..7306278 100755 --- a/bin/ngcp-create-subscriber +++ b/bin/ngcp-create-subscriber @@ -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 creates a subscriber on the NGCP platform. =over 8 -=item B<--customer_id> I +=item B<--customer-id> I 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 +=item B<--display-name> I 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) diff --git a/bin/ngcp-delete-domain b/bin/ngcp-delete-domain index 9f2cc91..8ce47d0 100755 --- a/bin/ngcp-delete-domain +++ b/bin/ngcp-delete-domain @@ -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. diff --git a/bin/ngcp-get-customer b/bin/ngcp-get-customer index b49a334..47e02e4 100755 --- a/bin/ngcp-get-customer +++ b/bin/ngcp-get-customer @@ -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 retreives a customer from the NGCP platform. =over 8 -=item B<--customer_id> I +=item B<--customer-id> I Customer id. diff --git a/bin/ngcp-terminate-customer b/bin/ngcp-terminate-customer index 9de5521..40ef1f9 100755 --- a/bin/ngcp-terminate-customer +++ b/bin/ngcp-terminate-customer @@ -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 terminates a customer on the NGCP platform. =over 8 -=item B<--customer_id> I +=item B<--customer-id> I Customer ID.