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

--- Comment #3 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 206086
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206086&action=edit
Bug 43546: (follow-up) Add --man and positional-argument support to
Koha::Script->describe_options

Converting the first real scripts to this convention (runreport.pl and
update_patrons_category.pl, in dependent bugs) surfaced two gaps in
what this bug set out to establish:

- Scripts with substantial existing POD (like runreport.pl and
  update_patrons_category.pl) previously had --help (brief) and --man
  (full Pod::Usage manual), often with --help+--verbose also
  triggering the full manual. describe_options' own --help covers the
  brief case, but had no equivalent to --man. Rather than reinvent
  that per-script, --man is now added automatically alongside --help:
  it prints the calling script's own POD in full (Pod::Usage -verbose
  2, defaulting to $0) and exits. --help+--verbose no longer triggers
  the full manual as a side effect; --verbose keeps its own, unrelated
  meaning of execution verbosity. Every script using describe_options
  gets --man for free.

- A positional-argument requirement (e.g. runreport.pl's report
  ID(s)) has no per-option 'required' flag to declare it with, so it
  would otherwise be left as manual post-parse validation -- exactly
  the kind of ad hoc, unenforced, unparseable check this bug exists to
  replace for named options. describe_options now accepts a
  declarative 'args' key (in the same trailing hashref as 'epilog'),
  e.g. C<args => { min => 1, name => 'reportID', variadic => 1 }>,
  enforced by describe_options itself with the same consistent
  error/usage output as a missing required option. This also gives
  static tooling (e.g. the koha-plugin-crontab plugin, which reads
  script source rather than executing it) a literal marker for a
  required positional argument, the same way it already reads
  'required => 1' for named options. describe_options also returns
  ($opt, $usage) in list context (unchanged in scalar context) for any
  post-parse validation 'args' doesn't cover.

Test plan:
1. prove t/Koha/Script.t
2. koha-qa.pl passes for Koha/Script.pm
(--man and args are exercised functionally by the scripts converted in
the dependent bugs)

Co-Authored-By: Claude Sonnet 5 <[email protected]>

-- 
You are receiving this mail because:
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