You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "serhiy-bzhezytskyy (via GitHub)" <gi...@apache.org> on 2026/10/07 04:35:47 UTC
[PR] SOLR-18517: Port RunExampleTool to picocli [solr]
serhiy-bzhezytskyy opened a new pull request, #5050:
URL: https://github.com/apache/solr/pull/5050
https://issues.apache.org/jira/browse/SOLR-18517
# Description
Adds the picocli code path for `run_example`, which `bin/solr start -e` calls, next to the commons-cli one.
# Solution
`RunExampleTool` gets its annotated options and `callTool()` and is registered in `SolrCLI`; the commons-cli path is unchanged. The options are the ones the `bin/solr` scripts pass, including `--script-inputs`. The command is only invoked by the scripts, so it is hidden and has no reference page. Written with Claude Code.
# Tests
`SolrCLIRunExamplePicocliTest` runs the existing `TestSolrCLIRunExample` through picocli, and checks that the port and `--zk-host` defaults come from the properties. With `SOLR_PICOCLI=true`, `bin/solr start -e techproducts` starts and indexes the example. `check -x test` is clean (rat skipped).
# Checklist
- [x] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability.
- [x] I have created a Jira issue and added the issue ID to my pull request title.
- [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
- [x] I have developed this patch against the `main` branch.
- [ ] I have run `./gradlew check`.
- [x] I have added tests for my changes.
- [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
- [x] I have added a [changelog entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my change
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-18517: Port RunExampleTool to picocli [solr]
Posted by "serhiy-bzhezytskyy (via GitHub)" <gi...@apache.org>.
serhiy-bzhezytskyy commented on code in PR #5050:
URL: https://github.com/apache/solr/pull/5050#discussion_r4207435977
##########
solr/core/src/java/org/apache/solr/cli/RunExampleTool.java:
##########
@@ -222,6 +307,122 @@ record RunExampleParams(boolean isCloudMode, String zkHost, int port, StartSolrP
record CloudExampleParams(
boolean noPrompt, String scriptInputs, String zkHost, int basePort, StartSolrParams start) {}
+ // --- picocli fields ---
+
+ @picocli.CommandLine.Option(
+ names = {"-y", "--no-prompt"},
+ description =
+ "Don't prompt for input; accept all defaults when running examples that accept user"
+ + " input.")
+ private boolean noPromptOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--script-inputs",
+ paramLabel = "VALUES",
+ description =
+ "Provide comma-separated values for prompts. Same as --no-prompt but uses provided"
+ + " values instead of defaults. Example: --script-inputs"
+ + " 3,8983,8984,8985,\"gettingstarted\",2,2,_default")
+ private String scriptInputsOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-e", "--example"},
+ required = true,
+ paramLabel = "NAME",
+ description =
+ "Name of the example to launch, one of: cloud, techproducts, schemaless, films.")
+ private String exampleOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--script",
+ paramLabel = "PATH",
+ description = "Path to the bin/solr script.")
+ private String scriptOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-d", "--server-dir"},
+ required = true,
+ paramLabel = "DIR",
+ description = "Path to the Solr server directory.")
+ private String serverDirOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-f", "--force"},
+ description = "Force option in case Solr is run as root.")
+ private boolean forceOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--example-dir",
+ paramLabel = "DIR",
+ description =
+ "Path to the Solr example directory; if not provided, ${serverDir}/../example is"
+ + " expected to exist.")
+ private String exampleDirOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--solr-home",
+ paramLabel = "SOLR_HOME_DIR",
+ description =
+ "Path to the Solr home directory; if not provided, ${serverDir}/solr is expected to"
+ + " exist.")
+ private String solrHomeOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--url-scheme",
+ defaultValue = "http",
+ paramLabel = "SCHEME",
+ description = "Solr URL scheme: http or https, defaults to http if not specified.")
+ private String urlSchemeOpt;
+
+ // No explicit paramLabel: the default "<port>" is what CliDefaultValueProvider keys on, giving
+ // the solr.port.listen property / SOLR_PORT_LISTEN, else 8983, as under commons-cli.
+ @picocli.CommandLine.Option(
+ names = {"-p", "--port"},
+ description = "Specify the port to start the Solr HTTP listener on; default is 8983.")
+ private int port;
+
+ @picocli.CommandLine.Option(
+ names = "--host",
+ paramLabel = "HOSTNAME",
+ description = "Specify the hostname for this Solr instance.")
+ private String hostOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--user-managed",
+ description = "Start Solr in User Managed mode.")
+ private boolean userManagedOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-m", "--memory"},
+ paramLabel = "MEM",
+ description =
+ "Sets the min (-Xms) and max (-Xmx) heap size for the JVM, such as: -m 4g results in:"
+ + " -Xms4g -Xmx4g; by default, this script sets the heap size to 512m.")
+ private String memoryOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--jvm-opts",
+ paramLabel = "OPTS",
+ description =
+ "Additional options to be passed to the JVM when starting example Solr server(s).")
+ private String jvmOptsOpt;
+
+ // Likewise "<zkHost>": the zkHost property / ZK_HOST, else null.
+ @picocli.CommandLine.Option(
+ names = {"-z", "--zk-host"},
+ description = "Zookeeper connection string.")
+ private String zkHost;
+
+ @picocli.CommandLine.Parameters(
+ arity = "0..*",
+ paramLabel = "ARG",
+ description = "Extra arguments passed through to the underlying bin/solr start command.")
+ private String[] extraArgsOpt = new String[0];
Review Comment:
Fixed in e59118c: `-D…` arguments are kept as extra arguments after the positional ones, and any other unknown option still gives picocli's usage error (exit 2). Checked with `bin/solr start -e techproducts -Dcustom.prop=1`.
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-18517: Port RunExampleTool to picocli [solr]
Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #5050:
URL: https://github.com/apache/solr/pull/5050#discussion_r4205515631
##########
changelog/unreleased/SOLR-18517-picocli-run-example.yml:
##########
@@ -0,0 +1,9 @@
+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
+
+title: Running an example with `bin/solr start -e` now works in the experimental picocli command line interface.
Review Comment:
Generic changelog comment, see other PR (add author/link to the main picocli yml file)
##########
solr/core/src/java/org/apache/solr/cli/RunExampleTool.java:
##########
@@ -222,6 +307,122 @@ record RunExampleParams(boolean isCloudMode, String zkHost, int port, StartSolrP
record CloudExampleParams(
boolean noPrompt, String scriptInputs, String zkHost, int basePort, StartSolrParams start) {}
+ // --- picocli fields ---
+
+ @picocli.CommandLine.Option(
+ names = {"-y", "--no-prompt"},
+ description =
+ "Don't prompt for input; accept all defaults when running examples that accept user"
+ + " input.")
+ private boolean noPromptOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--script-inputs",
+ paramLabel = "VALUES",
+ description =
+ "Provide comma-separated values for prompts. Same as --no-prompt but uses provided"
+ + " values instead of defaults. Example: --script-inputs"
+ + " 3,8983,8984,8985,\"gettingstarted\",2,2,_default")
+ private String scriptInputsOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-e", "--example"},
+ required = true,
+ paramLabel = "NAME",
+ description =
+ "Name of the example to launch, one of: cloud, techproducts, schemaless, films.")
+ private String exampleOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--script",
+ paramLabel = "PATH",
+ description = "Path to the bin/solr script.")
+ private String scriptOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-d", "--server-dir"},
+ required = true,
+ paramLabel = "DIR",
+ description = "Path to the Solr server directory.")
+ private String serverDirOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-f", "--force"},
+ description = "Force option in case Solr is run as root.")
+ private boolean forceOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--example-dir",
+ paramLabel = "DIR",
+ description =
+ "Path to the Solr example directory; if not provided, ${serverDir}/../example is"
+ + " expected to exist.")
+ private String exampleDirOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--solr-home",
+ paramLabel = "SOLR_HOME_DIR",
+ description =
+ "Path to the Solr home directory; if not provided, ${serverDir}/solr is expected to"
+ + " exist.")
+ private String solrHomeOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--url-scheme",
+ defaultValue = "http",
+ paramLabel = "SCHEME",
+ description = "Solr URL scheme: http or https, defaults to http if not specified.")
+ private String urlSchemeOpt;
+
+ // No explicit paramLabel: the default "<port>" is what CliDefaultValueProvider keys on, giving
+ // the solr.port.listen property / SOLR_PORT_LISTEN, else 8983, as under commons-cli.
+ @picocli.CommandLine.Option(
+ names = {"-p", "--port"},
+ description = "Specify the port to start the Solr HTTP listener on; default is 8983.")
+ private int port;
+
+ @picocli.CommandLine.Option(
+ names = "--host",
+ paramLabel = "HOSTNAME",
+ description = "Specify the hostname for this Solr instance.")
+ private String hostOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--user-managed",
+ description = "Start Solr in User Managed mode.")
+ private boolean userManagedOpt;
+
+ @picocli.CommandLine.Option(
+ names = {"-m", "--memory"},
+ paramLabel = "MEM",
+ description =
+ "Sets the min (-Xms) and max (-Xmx) heap size for the JVM, such as: -m 4g results in:"
+ + " -Xms4g -Xmx4g; by default, this script sets the heap size to 512m.")
+ private String memoryOpt;
+
+ @picocli.CommandLine.Option(
+ names = "--jvm-opts",
+ paramLabel = "OPTS",
+ description =
+ "Additional options to be passed to the JVM when starting example Solr server(s).")
+ private String jvmOptsOpt;
+
+ // Likewise "<zkHost>": the zkHost property / ZK_HOST, else null.
+ @picocli.CommandLine.Option(
+ names = {"-z", "--zk-host"},
+ description = "Zookeeper connection string.")
+ private String zkHost;
+
+ @picocli.CommandLine.Parameters(
+ arity = "0..*",
+ paramLabel = "ARG",
+ description = "Extra arguments passed through to the underlying bin/solr start command.")
+ private String[] extraArgsOpt = new String[0];
Review Comment:
Blocking: `bin/solr start -e <ex> -Dfoo=bar` forwards the `-D…` args to `run_example`. commons-cli strips them in `SolrCLI.parseCmdLine` and hands them to `readExtraArgs(cli.getArgs())`; on the picocli path nothing strips them and picocli rejects the first one (`Unknown option: '-Dfoo=bar'`, exit 2 — verified with picocli 4.7.6), so this positional never sees them. Suggest `@picocli.CommandLine.Unmatched List<String> unmatched`, keep the `-D…` entries for `readExtraArgs(...)` and fail on anything else, plus a test in `SolrCLIRunExamplePicocliTest` with `-Dcustom.prop=1` (what `test_example.bats` passes).
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-18517: Port RunExampleTool to picocli [solr]
Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy merged PR #5050:
URL: https://github.com/apache/solr/pull/5050
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org