X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Farchetypes%2Fopendaylight-startup%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fcli%2Fsrc%2Fmain%2Fjava%2F__packageInPathFormat__%2Fcli%2Fcommands%2F__classPrefix__CliTestCommand.java;fp=opendaylight%2Farchetypes%2Fopendaylight-startup%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fcli%2Fsrc%2Fmain%2Fjava%2F__packageInPathFormat__%2Fcli%2Fcommands%2F__classPrefix__CliTestCommand.java;h=65ec5f750d3ffb91b9de28469c4edea82c69a93e;hp=0000000000000000000000000000000000000000;hb=e64a4f7e0af0f6069658b5c2063fa7e79cb45c30;hpb=7c912dbbd4fefc97229bd0bdbb9d46391507ec9c diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/cli/src/main/java/__packageInPathFormat__/cli/commands/__classPrefix__CliTestCommand.java b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/cli/src/main/java/__packageInPathFormat__/cli/commands/__classPrefix__CliTestCommand.java new file mode 100644 index 0000000000..65ec5f750d --- /dev/null +++ b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/cli/src/main/java/__packageInPathFormat__/cli/commands/__classPrefix__CliTestCommand.java @@ -0,0 +1,56 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright © ${copyrightYear} ${copyright} and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package ${package}.cli.commands; + +import org.apache.karaf.shell.commands.Command; +import org.apache.karaf.shell.commands.Option; +import org.apache.karaf.shell.console.AbstractAction; +import ${package}.cli.api.${classPrefix}CliCommands; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is an example class. The class name can be renamed to match the command implementation that it will invoke. + * Specify command details by updating the fields in the Command annotation below. + */ +@Command(name = "test-command", scope = "add the scope of the command, usually project name", description = "add a description for the command") +public class ${classPrefix}CliTestCommand extends AbstractAction { + + private static final Logger LOG = LoggerFactory.getLogger(${classPrefix}CliTestCommand.class); + protected final ${classPrefix}CliCommands service; + + public ${classPrefix}CliTestCommand(final ${classPrefix}CliCommands service) { + this.service = service; + } + + /** + * Add the arguments required by the command. + * Any number of arguments can be added using the Option annotation + * The below argument is just an example and should be changed as per your requirements + */ + @Option(name = "-tA", + aliases = { "--testArgument" }, + description = "test command argument", + required = true, + multiValued = false) + private Object testArgument; + + @Override + protected Object doExecute() throws Exception { + /** + * Invoke commannd implementation here using the service instance. + * Implement how you want the output of the command to be displayed. + * Below is just an example. + */ + final String testMessage = (String) service.testCommand(testArgument); + return testMessage; + } +} \ No newline at end of file