summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-15 19:47:52 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-15 19:47:52 -0500
commit38b46e1b5d934ae5c4a4f70faa1e4fb7708f0935 (patch)
tree39d6a289f12147b0f6bca8b58b0113146aacb596 /cmd2.py
parent658777ce0dd2df1a1747d85a44aef87a2d5e6747 (diff)
downloadcmd2-git-38b46e1b5d934ae5c4a4f70faa1e4fb7708f0935.tar.gz
Added option to prevent processing of CLI args.
Addressed Issue #14.
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index 87cc4561..8540252c 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -502,6 +502,7 @@ class Cmd(cmd.Cmd):
# Attributes which are NOT dynamically settable at runtime
_STOP_AND_EXIT = True # distinguish end of script file from actual exit
_STOP_SCRIPT_NO_EXIT = -999
+ allow_cli_args = True
blankLinesAllowed = False
colorcodes = {'bold': {True: '\x1b[1m', False: '\x1b[22m'},
'cyan': {True: '\x1b[36m', False: '\x1b[39m'},
@@ -1654,9 +1655,13 @@ Script should contain one command per line, just like command would be typed in
if self.intro is not None:
self.stdout.write(str(self.intro) + "\n")
- # Process any commands present as arguments on the command-line
- if not self.run_commands_at_invocation(callargs):
- # And then call _cmdloop() if there wasn't something in those causing us to quit
+ stop = False
+ # If allowed, process any commands present as arguments on the command-line, if allowed
+ if self.allow_cli_args:
+ stop = self.run_commands_at_invocation(callargs)
+
+ # And then call _cmdloop() if there wasn't something in those causing us to quit
+ if not stop:
self._cmdloop()
# Run the postloop() no matter what