https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43557

--- Comment #1 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 206174
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206174&action=edit
Bug 43557: Add declarative mutually-exclusive option support to
Koha::Script->describe_options

Adds an exclusive key to the trailing options hashref of
Koha::Script->describe_options, alongside the existing required and
args support. Declaring exclusive => [ [qw(code exclude-code)], ... ]
makes a group of options mutually exclusive: if more than one is
actually given a value, the script dies with a clear, consistent error
and the usage text, the same as a missing required option already
does, instead of every script rolling its own pod2usage/die check.

Group members must be written using each option's first-declared spec
name, hyphens and all (e.g. exclude-code, not the accessor's
exclude_code) -- confirmed by testing that Getopt::Long::Descriptive's
_specified() introspection method needs that exact form, not the
canonicalised accessor name.

An option only counts as "given" if it was specified on the command
line and resolved to a non-empty value, so a bare optional-value (:s)
flag left over as an empty string (bug 37075) does not by itself
trigger the conflict -- this was tested directly against both scalar
and repeatable (:s@) option types.

Getopt::Long::Descriptive's own one_of constraint was considered as an
alternative, since it already provides exclusivity checking for a
group of options. Testing showed it does not enforce exclusivity at
all when the group's options are array/repeatable types: passing two
such options together with real values is silently accepted, which
would have been a regression for scripts like process_message_queue.pl
(bug 43551) whose --code/--exclude-code both take multiple values.

Test plan:
1. prove t/Koha/Script.t
2. koha-qa.pl passes for Koha/Script.pm

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to