summaryrefslogtreecommitdiff
path: root/scripts/targetcli
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2011-12-02 10:02:06 -0800
committerAndy Grover <agrover@redhat.com>2011-12-06 17:46:44 -0800
commit8fac19e3d5a0dc5e124aca27c3b96b43a1202af8 (patch)
tree6cd48cc49a52814d3d4388af8f3ac0d538c5690a /scripts/targetcli
parent691a6afc3178cb0ca15e97c4c1915f2638900408 (diff)
downloadtargetcli-8fac19e3d5a0dc5e124aca27c3b96b43a1202af8.tar.gz
Enable execution of cmdline parameters in targetcli
Check the commandline and only enter interactive shell if no additional parameters were given. If parameters were given, execute them and exit. Signed-off-by: Andy Grover <agrover@redhat.com>
Diffstat (limited to 'scripts/targetcli')
-rwxr-xr-xscripts/targetcli23
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/targetcli b/scripts/targetcli
index 877b0e7..3dd459f 100755
--- a/scripts/targetcli
+++ b/scripts/targetcli
@@ -24,6 +24,7 @@ from os import getuid
from targetcli import UIRoot
from rtslib import RTSLibError
from configshell import ConfigShell
+import sys
class TargetCLI(ConfigShell):
default_prefs = {'color_path': 'magenta',
@@ -55,13 +56,6 @@ def main():
is_root = False
shell = TargetCLI('~/.targetcli')
- shell.con.epy_write('''
- Welcome to the B{targetcli} shell::
- Copyright (c) 2011 by RisingTide Systems LLC.\n
- For help on commands, type 'help'.
-
- ''')
- shell.con.display('')
if not is_root:
shell.con.display('You are not root, disabling privileged commands.')
shell.con.display('')
@@ -72,8 +66,19 @@ def main():
root_node.refresh()
except RTSLibError, error:
shell.con.display(shell.con.render_text(str(error), 'red'))
- else:
- shell.run_interactive()
+
+ if len(sys.argv) > 1:
+ shell.run_cmdline(" ".join(sys.argv[1:]))
+ sys.exit(0)
+
+ shell.con.epy_write('''
+ Welcome to the B{targetcli} shell::
+ Copyright (c) 2011 by RisingTide Systems LLC.\n
+ For help on commands, type 'help'.
+
+ ''')
+ shell.con.display('')
+ shell.run_interactive()
if __name__ == "__main__":
main()