Jan Høydahl created SOLR-18521:
----------------------------------
Summary: Unify picocli shared connection options into one mixin
with built-in resolution
Key: SOLR-18521
URL: https://issues.apache.org/jira/browse/SOLR-18521
Project: Solr
Issue Type: Improvement
Components: cli
Reporter: Jan Høydahl
This sweeping clieanup is to be done *after* all tools are ported over to
picocli. (SOLR-18509, SOLR-18510, SOLR-18511, SOLR-18512, SOLR-18513,
SOLR-18514, SOLR-18516, SOLR-18517, SOLR-18518, SOLR-18519)
Following problem description researched and authored with Claude Code, and
approved by me
----
The picocli port (SOLR-17697) has three parallel declarations of the
{{\-\-solr\-connection}} / {{\-\-solr\-url}} / {{\-\-zk\-host}} options:
{{ConnectionOptions}} as an exclusive {{@ArgGroup}} (create, delete, version),
{{ZkConnectionOptions}} as a non-exclusive {{@Mixin}} that also re-declares
{{\-\-credentials}} (the zk-family tools), and a private clone in
{{StatusTool}}. Their descriptions have drifted, and the zk-family tools accept
{{\-\-zk\-host a \-\-solr\-url b}} while the URL-family tools reject it
(commons-cli rejects it everywhere).
picocli does not apply default-value-provider defaults to an unmatched
{{@ArgGroup}}, so the {{CliDefaultValueProvider}} fallback ({{ZK_HOST}},
{{SOLR_URL}}, {{SOLR_CONNECTION}}) never reaches the ArgGroup-based tools. Each
of them therefore hand-rolls its own URL resolution ({{connectionOptions !=
null ? ... : EnvUtils.getProperty("zkHost")}}); once the current round of ports
lands, {{main}} carries about eight copies with four different fallback
behaviours. There is also no shared "resolve a base Solr URL" counterpart to
{{ZkConnectionOptions.resolveZkHost()}}, and {{\-c/\-\-name}} is declared per
tool.
{{CliDefaultValueProvider}} keys its cases on {{argSpec.paramLabel()}}, i.e.
the Java field name, so renaming a field or setting an explicit {{paramLabel}}
silently disables the env fallback (SOLR-18517 carries comments working around
this).
Scope (picocli path only; the commons-cli path is untouched):
* One public {{ConnectionOptions}} {{@Mixin}} with {{resolveSolrUrl}},
{{resolveZkHost}}, {{resolveSolrConnection}} and {{hasExplicitConnection}}
built in, and programmatic mutual exclusion of explicitly passed options
(values populated from the environment do not count).
* Remove {{ZkConnectionOptions}} and {{StatusTool.TargetOptions}}; every tool
uses {{@Mixin ConnectionOptions}} + {{@Mixin CredentialsOptions}} and drops its
private resolver.
* {{CliDefaultValueProvider}} keyed by option name instead of {{paramLabel}}.
{{ApiTool}}'s {{\-\-solr\-url}} names a full endpoint URL, not a base URL, and
must opt out of the {{SOLR_URL}} default.
* {{CollectionNameOptions}} mixin for {{\-c/\-\-name}}.
* Regenerate the CLI reference pages; update the porting guide so new ports use
the mixin.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]