1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package it.jnrpe.server.console;
17
18 import java.io.IOException;
19
20 import jline.console.ConsoleReader;
21 import it.jnrpe.JNRPE;
22
23 public abstract class ConsoleCommand implements IConsoleCommand {
24 private final JNRPE jnrpeInstance;
25 private final ConsoleReader console;
26
27 public ConsoleCommand(ConsoleReader consoleReader, JNRPE jnrpe) {
28 jnrpeInstance = jnrpe;
29 console = consoleReader;
30 }
31
32 protected JNRPE getJNRPE() {
33 return jnrpeInstance;
34 }
35
36 protected ConsoleReader getConsole() {
37 return console;
38 }
39
40 protected void println(String msg) throws IOException {
41 getConsole().println(msg);
42 }
43
44 protected String highlight(final String msg) {
45 if (msg == null){
46 throw new IllegalArgumentException("Message can't be null");
47 }
48
49 return new StringBuffer("\u001B[1m")
50 .append(msg)
51 .append("\u001B[0m").toString();
52 }
53 }