From 455485185e4a452bbafb7121054249f319f7eda9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 23 Feb 2014 18:11:05 +0100 Subject: add cmdline correctness test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- TODO | 1 - src/__main__.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 0e58971..18b64f3 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,6 @@ Medium priority: Small examples -r support in the comperhensive example Store settings so that we can transition from them instead of from clean - Verify command line option correctness Low priority: Fix errors caused by SIGUSR2 diff --git a/src/__main__.py b/src/__main__.py index f189e16..d4c9d4d 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -356,6 +356,20 @@ output = parser.opts['--output'] if output is None: output = [] +if config_file is not None: + if any([doreset, location, gammas, rgb_brightnesses, cie_brightnesses, temperatures, output]): + print('--configurations can only be combined with --panicgate') + sys.exit(1) + +a = lambda opt : 0 if parser.opts[opt] is None else len(parser.opts[opt]) +for opt in ('--configurations', '--panicgate', '--reset', '--location'): + if a(opt) > 1: + print('%s can only be used once' % opt) + sys.exit(1) +for opt in ('--gamma', '--brightness', '++brightness', '--temperature'): + if a(opt) > 2: + print('%s can only be used up to two times' % opt) + sys.exit(1) settings = [gammas, rgb_brightnesses, cie_brightnesses, temperatures] if (config_file is None) and any([doreset, location] + settings): -- cgit v1.2.3-70-g09d2