over.app: add proper bool usage check

This commit is contained in:
Martinez 2016-05-17 16:55:14 +02:00
parent 2757cd8e96
commit 17eda81ad2

View file

@ -79,6 +79,13 @@ class IncompleteArguments(Exception):
return "option --%s takes a %d-word argument but has received %s" %(option_name, option_count, received or "none")
class BoolUsageError(Exception):
@property
def description(self):
option_name = self.args[0]
return "option --%s is not boolean so you can't use --no-%s" %(option_name, option_name)
class NotAList(Exception):
"""
Option defaults must be in a list.
@ -459,6 +466,9 @@ class Main:
except KeyError:
raise UnknownOption(token)
if not option_is_positive and not option.is_boolean:
raise BoolUsageError(option.name)
last_read_option = option
# single booleans are handled specially because of their --option/--no-option forms