File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 44
55from . import Cli , CliError , ArgumentParser
66from .common import proptagCompleter
7+ import locale
8+ import termios
79
810
911def _runParserSetup (subp : ArgumentParser ):
@@ -135,6 +137,16 @@ def _loadHistory(args):
135137 .format (filePath , type (err ).__name__ + " - " .join (str (arg ) for arg in err .args )),
136138 attrs = ["dark" ]))
137139
140+ def eof_instructions (fd ):
141+ try :
142+ key = termios .tcgetattr (fd )[6 ][termios .VEOF ]
143+ if ord (key ) == 0 :
144+ return ""
145+ if ord (key ) < 32 :
146+ return " or press CTRL+" + chr (ord (key ) + ord ('@' ))
147+ return " or press '" + key .decode (locale .getpreferredencoding ()) + "'"
148+ except :
149+ return ""
138150
139151@Cli .command ("shell" , _setupCliShell , help = "Start interactive shell" )
140152def cliShell (args ):
@@ -157,9 +169,9 @@ def rlEnable(state):
157169 if interactive :
158170 cli .print ("\x1b ]2;grommunio-admin\x07 " , end = "" )
159171 if cli .host is None :
160- cli .print ("grommunio-admin shell. Type exit or press CTRL+D to exit." )
172+ cli .print ("grommunio-admin shell. Type ` exit`" + eof_instructions ( cli . stdin ) + " to exit." )
161173 else :
162- cli .print ("Starting remote admin shell. Type exit or press CTRL+D to exit." )
174+ cli .print ("Starting remote admin shell. Type ` exit`" + eof_instructions ( cli . stdin ) + " to exit." )
163175 try :
164176 import readline
165177 readline .set_completer_delims ("" )
You can’t perform that action at this time.
0 commit comments