Skip to content

SOLR-17697 Implement picocli for create and delete commands#4269

Open
janhoy wants to merge 4 commits intoapache:jira/SOLR-17697-picoclifrom
janhoy:picocli-create-tool
Open

SOLR-17697 Implement picocli for create and delete commands#4269
janhoy wants to merge 4 commits intoapache:jira/SOLR-17697-picoclifrom
janhoy:picocli-create-tool

Conversation

@janhoy
Copy link
Copy Markdown
Contributor

@janhoy janhoy commented Apr 7, 2026

Usage: solr create [-hvV] -c=<name> [-d=<confDir>] [-n=<confName>] [-rf=<replicationFactor>] [-sh=<shards>] [-u=<credentials>] [-s=<solrUrl> | -z=<zkHost>]
Creates a core or collection depending on whether Solr is running in standalone (core) or SolrCloud mode (collection).
  -c, --name=<name>          Name of collection or core to create.
  -d, --conf-dir=<confDir>   Configuration directory to copy when creating the new collection; default is _default.
  -h, --help                 Show this help message and exit.
  -n, --conf-name=<confName> Configuration name; default is the collection name.
      -rf, --replication-factor=<replicationFactor>
                             Number of copies of each document across the collection (replicas per shard); default is 1.
  -s, --solr-url=<solrUrl>   Base Solr URL, which can be used to determine the zk-host if that's not known.
      -sh, --shards=<shards> Number of shards; default is 1.
  -u, --credentials=<credentials>
                             Credentials in the format username:password. Example: --credentials solr:SolrRocks
  -v, --verbose              Enable verbose mode.
  -V, --version              Print version information and exit.
  -z, --zk-host=<zkHost>     Zookeeper connection string; unnecessary if ZK_HOST is defined in solr.in.sh; otherwise, defaults to localhost:9983.

For a full CLI reference, see https://solr.apache.org/guide/solr/latest/deployment-guide/solr-control-script-reference.html
Usage: solr delete [-fhvV] [--delete-config] -c=<name> [-u=<credentials>] [-s=<solrUrl> | -z=<zkHost>]
Deletes a collection or core depending on whether Solr is running in SolrCloud or standalone mode.
  -c, --name=<name>          Name of the core / collection to delete.
      --delete-config        Flag to indicate if the underlying configuration directory for a collection should also be deleted; default is false.
  -f, --force                Skip safety checks when deleting the configuration directory used by a collection.
  -h, --help                 Show this help message and exit.
  -s, --solr-url=<solrUrl>   Base Solr URL, which can be used to determine the zk-host if that's not known.
  -u, --credentials=<credentials>
                             Credentials in the format username:password. Example: --credentials solr:SolrRocks
  -v, --verbose              Enable verbose mode.
  -V, --version              Print version information and exit.
  -z, --zk-host=<zkHost>     Zookeeper connection string; unnecessary if ZK_HOST is defined in solr.in.sh; otherwise, defaults to localhost:9983.

For a full CLI reference, see https://solr.apache.org/guide/solr/latest/deployment-guide/solr-control-script-reference.html

https://issues.apache.org/jira/browse/SOLR-17697

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements picocli-based parsing/execution for the existing solr create and solr delete CLI commands, and wires them into the picocli-enabled solr entrypoint to support the new usage/help output shown in the PR description.

Changes:

  • Register CreateTool and DeleteTool as picocli subcommands of SolrCLI.
  • Add picocli option mixins/shared option groups (CredentialsOptions, ConnectionOptions) and implement callTool() paths for create/delete.
  • Relax a packaging BATS assertion to accommodate picocli’s mutual-exclusion error wording.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
solr/packaging/test/test_create.bats Updates assertion for mutually-exclusive connection options under picocli.
solr/core/src/java/org/apache/solr/cli/SolrCLI.java Adds create and delete as picocli subcommands.
solr/core/src/java/org/apache/solr/cli/CreateTool.java Adds picocli annotations/fields and implements callTool() logic for create.
solr/core/src/java/org/apache/solr/cli/DeleteTool.java Adds picocli annotations/fields and implements callTool() logic for delete.
solr/core/src/java/org/apache/solr/cli/CredentialsOptions.java New picocli mixin for --credentials.
solr/core/src/java/org/apache/solr/cli/ConnectionOptions.java New picocli ArgGroup for mutually-exclusive --solr-url/--zk-host.
Comments suppressed due to low confidence (1)

solr/core/src/java/org/apache/solr/cli/DeleteTool.java:210

  • This warning suggests passing --force-delete-config, but the actual option defined by this tool is -f/--force (and there is no --force-delete-config). Update the message to reference the correct flag so users can resolve the warning.
          log.warn(
              "Configuration directory {} is also being used by {}{}",
              configName,
              inUse.get(),
              "; configuration will not be deleted from ZooKeeper. You can pass the --force-delete-config flag to force delete.");
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants