mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 19:44:52 +00:00
Show an error instead of crashing when trying to use a command option without a required argument
This commit is contained in:
parent
2b31544754
commit
fb4e4856d1
1 changed files with 7 additions and 2 deletions
|
@ -86,7 +86,7 @@ class OptionParser(optparse.OptionParser):
|
|||
If you override this in a subclass, it should not return -- it
|
||||
should either exit or raise an exception.
|
||||
"""
|
||||
raise
|
||||
raise Exception(msg)
|
||||
|
||||
class BaseCommand(object):
|
||||
|
||||
|
@ -266,7 +266,12 @@ class ConsoleUI(component.Component):
|
|||
parser._print_help(f)
|
||||
parser.print_help = print_help
|
||||
|
||||
options, args = parser.parse_args(args)
|
||||
try:
|
||||
options, args = parser.parse_args(args)
|
||||
except Exception, e:
|
||||
self.write("{!error!}Error parsing options: %s" % e)
|
||||
return
|
||||
|
||||
if not getattr(options, '_exit', False):
|
||||
try:
|
||||
ret = self._commands[cmd].handle(*args, **options.__dict__)
|
||||
|
|
Loading…
Add table
Reference in a new issue