rm README.OPENDAYLIGHT (badly outdated)
[controller.git] / opendaylight / archetypes / opendaylight-startup / src / main / resources / archetype-resources / cli / src / main / java / __packageInPathFormat__ / cli / commands / __classPrefix__CliTestCommand.java
1 #set( $symbol_pound = '#' )
2 #set( $symbol_dollar = '$' )
3 #set( $symbol_escape = '\' )
4 /*
5  * Copyright © ${copyrightYear} ${copyright} and others.  All rights reserved.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
9  * and is available at http://www.eclipse.org/legal/epl-v10.html
10  */
11 package ${package}.cli.commands;
12
13 import org.apache.karaf.shell.commands.Command;
14 import org.apache.karaf.shell.commands.Option;
15 import org.apache.karaf.shell.console.AbstractAction;
16 import ${package}.cli.api.${classPrefix}CliCommands;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * This is an example class. The class name can be renamed to match the command implementation that it will invoke.
22  * Specify command details by updating the fields in the Command annotation below.
23  */
24 @Command(name = "test-command", scope = "add the scope of the command, usually project name",
25         description = "add a description for the command")
26 public class ${classPrefix}CliTestCommand extends AbstractAction {
27
28     private static final Logger LOG = LoggerFactory.getLogger(${classPrefix}CliTestCommand.class);
29     protected final ${classPrefix}CliCommands service;
30
31     public ${classPrefix}CliTestCommand(final ${classPrefix}CliCommands service) {
32         this.service = service;
33     }
34
35     /**
36      * Add the arguments required by the command.
37      * Any number of arguments can be added using the Option annotation
38      * The below argument is just an example and should be changed as per your requirements
39      */
40     @Option(name = "-tA",
41             aliases = { "--testArgument" },
42             description = "test command argument",
43             required = true,
44             multiValued = false)
45     private Object testArgument;
46
47     @Override
48     protected Object doExecute() throws Exception {
49         /**
50          * Invoke commannd implementation here using the service instance.
51          * Implement how you want the output of the command to be displayed.
52          * Below is just an example.
53          */
54         final String testMessage = (String) service.testCommand(testArgument);
55         return testMessage;
56     }
57 }