From 17eda81ad2f012c978cfc943d105c2cd2ed1a7aa Mon Sep 17 00:00:00 2001 From: Martinez Date: Tue, 17 May 2016 16:55:14 +0200 Subject: [PATCH] over.app: add proper bool usage check --- over/app.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/over/app.py b/over/app.py index 10b55d4..dbd72b1 100644 --- a/over/app.py +++ b/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