over.app: add proper bool usage check
This commit is contained in:
parent
2757cd8e96
commit
17eda81ad2
1 changed files with 10 additions and 0 deletions
10
over/app.py
10
over/app.py
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue