summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2019-10-18 19:43:25 +0530
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2019-10-30 16:00:04 +0530
commit24cc497c02b97b834d535431ec50d3f75c18ddcd (patch)
treecb856e2af609040f9863d4779422db26af6b164b
parentb36f0a0e27cdea9128cdf71e696e05bdfd12e462 (diff)
downloadtargetcli-24cc497c02b97b834d535431ec50d3f75c18ddcd.tar.gz
cli: show useful hint in header area of shell in daemonized mode
Problem: ------- When auto_use_daemon=true, entering multi-line command-mode/shell-mode appears like the cli is stuck for new users, as we do not display any info now :-) $ targetcli ---- nothing here, is it stuck ? ------- $ targetcli cd /backstores/ get global auto_use_daemon pwd ls exit auto_use_daemon=true /backstores o- backstores ................................................ [...] o- block .................................... [Storage Objects: 0] o- fileio ................................... [Storage Objects: 0] o- pscsi .................................... [Storage Objects: 0] o- ramdisk .................................. [Storage Objects: 0] o- user:glfs ................................ [Storage Objects: 0] Solution: ------- Add some userful info and a '/> ' in each line, $ targetcli targetcli shell version 2.1.50 Entering targetcli batch mode for daemonized approach. Enter multiple commands separated by newline and type 'exit' to run them all in one go. /> cd /backstores/ /> get global auto_use_daemon /> pwd /> ls /> exit auto_use_daemon=true /backstores o- backstores ................................................ [...] o- block .................................... [Storage Objects: 0] o- fileio ................................... [Storage Objects: 0] o- pscsi .................................... [Storage Objects: 0] o- ramdisk .................................. [Storage Objects: 0] o- user:glfs ................................ [Storage Objects: 0] Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
-rwxr-xr-xscripts/targetcli10
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/targetcli b/scripts/targetcli
index 9009a14..49355e3 100755
--- a/scripts/targetcli
+++ b/scripts/targetcli
@@ -163,7 +163,7 @@ def call_daemon(shell, req):
sock.close()
sys.exit(0)
-def get_arguments():
+def get_arguments(shell):
readline.set_completer(completer)
readline.set_completer_delims('')
@@ -180,7 +180,13 @@ def get_arguments():
command = " ".join(sys.argv[argstart:])
else:
inputs = []
+ shell.con.display("targetcli shell version %s\n"
+ "Entering targetcli batch mode for daemonized approach.\n"
+ "Enter multiple commands separated by newline and "
+ "type 'exit' to run them all in one go.\n"
+ % targetcli_version)
while True:
+ shell.con.raw_write("/> ")
command = six.moves.input()
if command.lower() == "exit":
break
@@ -227,7 +233,7 @@ def main():
disable_daemon=True
if use_daemon and not disable_daemon:
- call_daemon(shell, get_arguments().encode())
+ call_daemon(shell, get_arguments(shell).encode())
# does not return
try: