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