54ada939db1d1624f4865a0129948b8eeba2e50e
[nemo.git] / nemo-tools / sandbox / src / main / java / org / opendaylight / nemo / tool / sandbox / EasyCli.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. 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
9 package org.opendaylight.nemo.tool.sandbox;
10
11 import asg.cliche.Shell;
12 import asg.cliche.ShellFactory;
13
14 import java.io.IOException;
15
16 /**
17  * Created by hj on 12/9/15.
18  */
19 public class EasyCli {
20     private Shell shell;
21
22     public EasyCli(String prompt,String hint,Object handler){
23         shell = ShellFactory.createConsoleShell(prompt, hint, handler);
24     }
25
26     public void add(Object handler){
27         shell.addMainHandler(handler,"");
28     }
29
30     public void run(){
31         try {
32             shell.commandLoop();
33         } catch (IOException e) {
34             e.printStackTrace();
35         }
36     }
37 }