brbzull0 opened a new pull request, #13861:
URL: https://github.com/apache/trafficserver/pull/13861
Fixes #13746
Fixes #13648
## Problem
- #13746: every command scans the whole rest of the command line for its own
options, and that scan did not honour `--`. A value spelled like a global
option was taken as that option even after `--`: `traffic_ctl config set <rec>
-- -f` failed with a usage error, and `traffic_ctl config set <rec> -- -h`
printed the help and exited 0 without setting anything.
- #13648: the five file-scope variables holding the parser-wide state had
external linkage, so libtscore exported them under generic names such as
`description`, and a unit test that set a default command or reached the help
path left that state behind for the next test.
## What this PR does
- The option scan skips `--` and the token after it, and leaves both to the
option or command that owns them, which already honours the escape.
Tests: `Double dash keeps a value away from an outer command's options` in
`test_ArgParser.cc`; `traffic_ctl_cold_config` runs 21-26.
- traffic_ctl's global `--watch` and `config reload`'s `--initial-wait` both
declared `-w`. The global is read first and took it, so the documented
`--initial-wait, -w` did not work. `-w` stays on `--watch`, as it behaves
today, and `--initial-wait` is long-only.
Tests: `config_reload_directive_cli` Test 14 and the help check after it;
`traffic_ctl_cold_config` runs 27-29.
- The `AddConfigReload` AuTest helper passed `-w`, which went to `--watch`.
It now passes `--initial-wait` only when a test asks for one, so the tests keep
the wait they ran with.
- The parser-wide state moves into an anonymous namespace, with a test-only
`ArgParser::reset_global_state()`.
Tests: `reset_global_state clears every piece of parser-wide state`, `The
default command retry replaces the failed pass's values`, and a link-time pin
in `test_ArgParser.cc`: it defines globals of the same names, so exporting them
again fails the link.
- Docs: `ArgParser.en.rst`, `traffic_ctl.en.rst`, `config-reload-ext.en.rst`
and a note in `upgrading.en.rst`.
## Behaviour change
A `--` written directly before a global option now protects that token,
which is what #13746 asks for: `traffic_ctl config set NAME -- -f` sets the
record to `-f`. A line that relied on the global option taking the token after
`--`, such as `traffic_ctl config set NAME -- -w 5 VAL`, is now refused.
## What this PR does not do
- An outer option taking a subcommand's option as its value (`traffic_ctl
config reload -f -m`, #13597) is handled in a separate PR stacked on this one.
- Only the token right after `--` is kept away from the outer scans. A
second token after it is still seen by them, as on master (`traffic_ctl config
set -- REC -h` prints the help). That can be a follow-up if wanted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]