diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-08-24 11:24:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-24 11:24:20 -0400 |
commit | 8c0abd3c1adb204737851c06cb9eeba16791f2c4 (patch) | |
tree | a362ef8db06f20252ed86e1cdec07b4cb60b274e /cmd2 | |
parent | 0ad6b6d5417d0d126dc39550d5416f266cc47ec5 (diff) | |
parent | d567570faf490d052f3f74a65a6af6aa338d965a (diff) | |
download | cmd2-git-8c0abd3c1adb204737851c06cb9eeba16791f2c4.tar.gz |
Merge pull request #507 from python-cmd2/exit_code
Added way of returning a non-zero exit code to the shell
Diffstat (limited to 'cmd2')
-rw-r--r-- | cmd2/cmd2.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 58972232..a17e128f 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -523,6 +523,9 @@ class Cmd(cmd.Cmd): # This boolean flag determines whether or not the cmd2 application can interact with the clipboard self.can_clip = can_clip + # This determines if a non-zero exit code should be used when exiting the application + self.exit_code = None + # ----- Methods related to presenting output to the user ----- @property @@ -3227,6 +3230,9 @@ Script should contain one command per line, just like command would be typed in func() self.postloop() + if self.exit_code is not None: + sys.exit(self.exit_code) + ### # # plugin related functions |