vppctl: clean exit cli when ctrl-d or ctrl-c entered
Ctrl-D now exits vpp cli using do_EOF function Ctrl-C now exits cleanly without KeyboardInterrupt Error Change-Id: I09d103df57b9512e572eb66c17c548b9c1801589 Signed-off-by: Padraig Connolly <padraig.connolly@intel.com>
This commit is contained in:

committed by
Chris Luke

parent
a92501ab70
commit
1f417aac76
30
vpp-api-test/scripts/vppctl
Normal file → Executable file
30
vpp-api-test/scripts/vppctl
Normal file → Executable file
@ -72,12 +72,16 @@ class Vppctl(Cmd):
|
|||||||
|
|
||||||
def do_exit(self, line):
|
def do_exit(self, line):
|
||||||
self.historyWrite()
|
self.historyWrite()
|
||||||
|
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
def emptyline(self):
|
def emptyline(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def do_EOF(self,line):
|
||||||
|
self.historyWrite()
|
||||||
|
sys.stdout.write('\n')
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
def preloop(self):
|
def preloop(self):
|
||||||
if readline and os.path.exists(persishist):
|
if readline and os.path.exists(persishist):
|
||||||
readline.read_history_file(persishist)
|
readline.read_history_file(persishist)
|
||||||
@ -91,16 +95,22 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if not len(command_args) > 1:
|
if not len(command_args) > 1:
|
||||||
prompt = Vppctl()
|
prompt = Vppctl()
|
||||||
red_set = '\033[31m'
|
red_set = '\033[31m'
|
||||||
norm_set = '\033[0m'
|
norm_set = '\033[0m'
|
||||||
if sys.stdout.isatty():
|
if sys.stdout.isatty():
|
||||||
prompt.prompt = 'vpp# '
|
prompt.prompt = 'vpp# '
|
||||||
prompt.cmdloop(red_set + " _______ _ " + norm_set + " _ _____ ___ \n" +
|
try:
|
||||||
red_set + " __/ __/ _ \ (_)__ " + norm_set + " | | / / _ \/ _ \\\n" +
|
prompt.cmdloop(red_set + " _______ _ " + norm_set + " _ _____ ___ \n" +
|
||||||
red_set + " _/ _// // / / / _ \\" + norm_set + " | |/ / ___/ ___/\n" +
|
red_set + " __/ __/ _ \ (_)__ " + norm_set + " | | / / _ \/ _ \\\n" +
|
||||||
red_set + " /_/ /____(_)_/\___/ " + norm_set + "|___/_/ /_/ \n")
|
red_set + " _/ _// // / / / _ \\" + norm_set + " | |/ / ___/ ___/\n" +
|
||||||
else:
|
red_set + " /_/ /____(_)_/\___/ " + norm_set + "|___/_/ /_/ \n")
|
||||||
prompt.cmdloop()
|
except KeyboardInterrupt:
|
||||||
|
sys.stdout.write('\n')
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
prompt.cmdloop()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.stdout.write('\n')
|
||||||
else:
|
else:
|
||||||
del command_args[0]
|
del command_args[0]
|
||||||
stdout_value = " ".join(command_args)
|
stdout_value = " ".join(command_args)
|
||||||
|
Reference in New Issue
Block a user