summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorCatherine Devlin <catherine.devlin@gmail.com>2008-05-20 12:56:05 -0400
committerCatherine Devlin <catherine.devlin@gmail.com>2008-05-20 12:56:05 -0400
commitcabb780e2159d9784571af33ec62465e31a01a1d (patch)
tree4b7a209b4ff909822ae9082204dd3a27819936c2 /cmd2.py
parent89f234f2d6e30afa0a5132b857221af0c160b798 (diff)
downloadcmd2-git-cabb780e2159d9784571af33ec62465e31a01a1d.tar.gz
cleaned up: proper exit after -h, -v
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py25
1 files changed, 0 insertions, 25 deletions
diff --git a/cmd2.py b/cmd2.py
index 01463b66..05cb611e 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -21,34 +21,11 @@ flagReader.py options are still supported for backward compatibility
import cmd, re, os, sys, optparse, subprocess, tempfile
from optparse import make_option
-class Option(optparse.Option):
- # optparse.Option.take_action keeps trying to use sys.exit. That's very rude.
- # We don't want to exit, we just want to know so we can terminate a particular
- # function call.
- def take_action(self, action, dest, opt, value, values, parser):
- if action == "help":
- parser.print_help()
- parser.exit()
- setattr(values, '_exit', True)
- elif action == "version":
- parser.print_version()
- parser.exit()
- setattr(values, '_exit', True)
-
- else:
- return optparse.Option.take_action(self, action, dest, opt, value, values, parser)
-
- return 1
-
-#make_option = Option
-
class OptionParser(optparse.OptionParser):
def exit(self, status=0, msg=None):
self.values._exit = True
if msg:
print msg
- # though we must trap and prevent the exit, we also want to end whatever command
- # was called
def error(self, msg):
"""error(msg : string)
@@ -57,8 +34,6 @@ class OptionParser(optparse.OptionParser):
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""
- #print msg
- #print self.format_help()
raise
def options(option_list):