[
https://issues.apache.org/jira/browse/SOLR-18654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154182#comment-18154182
]
ASF subversion and git services commented on SOLR-18654:
--------------------------------------------------------
Commit 7e168e228d538a15767d8399d10f53f153058090 in solr's branch
refs/heads/main from Prithvi S
[ https://gitbox.apache.org/repos/asf?p=solr.git;h=7e168e228d5 ]
SOLR-18649 SOLR-18654: fix CLI help and missing-subcommand exit codes (#5337)
Signed-off-by: prithvi <[email protected]>
> Parent commands exit 0 when given no sub-command, so an incomplete command
> reports success
> ------------------------------------------------------------------------------------------
>
> Key: SOLR-18654
> URL: https://issues.apache.org/jira/browse/SOLR-18654
> Project: Solr
> Issue Type: Bug
> Components: cli
> Reporter: Jan Høydahl
> Priority: Major
> Labels: cats
>
> *Found by CATS*, the cross-platform CLI test framework proposed in SOLR-18642
> — see [PR #5323|https://github.com/apache/solr/pull/5323]. A concrete
> instance of SOLR-16794.
> h3. Problem
> A parent command given no sub-command prints its help and exits *0*, so a
> caller cannot tell an incomplete command from one that did some work. {{solr
> zk}}, {{solr snapshot}} and {{solr package}} all behave this way, on the
> picocli path that SOLR-18561 has just made the default and identically under
> {{SOLR_PICOCLI=false}}.
> Solr answers the same class of mistake three different ways:
> || command || exit ||
> | {{solr}} | 1 |
> | {{solr zk}}, {{solr snapshot}}, {{solr package}} | *0* |
> | {{solr nosuchcommand}} | 2 |
> h3. Steps to reproduce
> {code}solr zk{code}
> Prints usage, exits 0.
> h3. Which code is right
> Practice elsewhere is split: {{go mod}} exits 2 and {{git worktree}} exits
> 129, while {{docker image}}, {{gh repo}} and {{helm repo}} all exit 0. So
> convention alone does not settle it.
> Picocli does. Its own default for a parent command invoked without a
> sub-command is to fail with "Missing required subcommand" and exit *2*; Solr
> opts out of that by giving each parent a {{Callable}} that prints usage and
> returns 0. 2 is also what {{solr nosuchcommand}} already returns, so it costs
> nothing to adopt.
> Recommendation: 2 for a missing sub-command, bare {{solr}} included. An
> explicit {{\-\-help}} should remain 0 everywhere, which is SOLR-18649.
> 🤖 AI Assisted
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]