janhoy commented on code in PR #4695:
URL: https://github.com/apache/solr/pull/4695#discussion_r3708666778
##########
solr/core/src/java/org/apache/solr/cli/PackageTool.java:
##########
@@ -129,149 +129,67 @@ public void runImpl(CommandLine cli) throws Exception {
String cmd = cli.getArgs()[0];
- try (SolrClient solrClient = CLIUtils.getSolrClient(cli, true)) {
+ try (SolrClient solrClient =
+ CLIUtils.getSolrClient(
+ solrUrl,
cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION), true)) {
packageManager = new PackageManager(runtime, solrClient, solrUrl,
zkHost);
try {
repositoryManager = new RepositoryManager(solrClient,
packageManager);
+ // Dispatches to a parser-independent method per sub-command
switch (cmd) {
case "add-repo":
- String repoName = cli.getArgs()[1];
- String repoUrl = cli.getArgs()[2];
- repositoryManager.addRepository(repoName, repoUrl);
- printGreen("Added repository: " + repoName);
+ addRepo(cli.getArgs()[1], cli.getArgs()[2]);
break;
case "add-key":
- String keyFilename = cli.getArgs()[1];
- Path path = Path.of(keyFilename);
- repositoryManager.addKey(Files.readAllBytes(path),
path.getFileName().toString());
+ addKey(Path.of(cli.getArgs()[1]));
break;
case "list-installed":
- printGreen("Installed packages:\n-----");
- for (SolrPackageInstance pkg :
packageManager.fetchInstalledPackageInstances()) {
- printGreen(pkg);
- }
+ listInstalled();
break;
case "list-available":
- printGreen("Available packages:\n-----");
Review Comment:
Ah, there's not any functional change, we just move code out from this
switch to methods, so the meat of list-available is moved to method
`listAvailable()` on line 229-237, including printGreen...
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]