nandakumar131 commented on code in PR #8030: URL: https://github.com/apache/ozone/pull/8030#discussion_r1987570337
########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/utils/AutoCompletion.java: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.utils; + +import org.apache.hadoop.hdds.scm.server.StorageContainerManagerStarter; +import org.apache.hadoop.ozone.HddsDatanodeService; +import org.apache.hadoop.ozone.admin.OzoneAdmin; +import org.apache.hadoop.ozone.audit.parser.AuditParser; +import org.apache.hadoop.ozone.conf.OzoneGetConf; +import org.apache.hadoop.ozone.csi.CsiServer; +import org.apache.hadoop.ozone.debug.OzoneDebug; +import org.apache.hadoop.ozone.freon.Freon; +import org.apache.hadoop.ozone.genconf.GenerateOzoneRequiredConfigurations; +import org.apache.hadoop.ozone.insight.Insight; +import org.apache.hadoop.ozone.om.OzoneManagerStarter; +import org.apache.hadoop.ozone.recon.ReconServer; +import org.apache.hadoop.ozone.repair.OzoneRepair; +import org.apache.hadoop.ozone.s3.Gateway; +import org.apache.hadoop.ozone.shell.OzoneRatis; +import org.apache.hadoop.ozone.shell.OzoneShell; +import org.apache.hadoop.ozone.shell.checknative.CheckNative; +import org.apache.hadoop.ozone.shell.s3.S3Shell; +import org.apache.hadoop.ozone.shell.tenant.TenantShell; +import picocli.AutoComplete; +import picocli.CommandLine; +import picocli.CommandLine.Option; + +/** + * Tool to generate bash/zsh auto-complete scripts for Ozone CLI. + */ +public final class AutoCompletion { + + private AutoCompletion() { } + + public static void main(String[] args) { + + CommandLine hierarchy = new CommandLine(new Ozone()) + .addSubcommand("admin", new OzoneAdmin().getCmd()) + .addSubcommand("auditparser", new AuditParser().getCmd()) + .addSubcommand("checknative", new CheckNative().getCmd()) + .addSubcommand("csi", new CsiServer().getCmd()) + .addSubcommand("datanode", new HddsDatanodeService().getCmd()) + .addSubcommand("debug", new OzoneDebug().getCmd()) + .addSubcommand("freon", new Freon().getCmd()) + .addSubcommand("genconf", new GenerateOzoneRequiredConfigurations().getCmd()) + .addSubcommand("getconf", new OzoneGetConf().getCmd()) + .addSubcommand("httpfs", new HttpFSServerWebServer()) + .addSubcommand("insight", new Insight().getCmd()) + .addSubcommand("om", new OzoneManagerStarter(null).getCmd()) + .addSubcommand("ratis", new OzoneRatis().getCmd()) + .addSubcommand("recon", new ReconServer().getCmd()) + .addSubcommand("repair", new OzoneRepair().getCmd()) + .addSubcommand("s3", new S3Shell().getCmd()) + .addSubcommand("s3g", new Gateway().getCmd()) + .addSubcommand("scm", new StorageContainerManagerStarter(null).getCmd()) + .addSubcommand("sh", new OzoneShell().getCmd(), "shell") + .addSubcommand("tenant", new TenantShell().getCmd()) + .addSubcommand("version", new OzoneVersionInfo()); Review Comment: Thanks for the suggestion @adoroszlai. I was planning on doing this. 😄 Just wanted to make sure that everything is working in first place. As of now, we don't have any command without no-args constructor that needs auto-complete. I will add dynamic loading of `GenericCli` implementation. `OzoneVersionInfo` is an exception. We should either make `OzoneVersionInfo` extend `GenericCli` or add it in a hard-coded way. For now I will add it directly and have a follow-up jira to make `OzoneVersionInfo` extend `GenericCli`. -- 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]
