From 8f64deefd63a67a58d508332e53f31df23fa31d5 Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Mon, 12 Sep 2022 20:31:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Make=20required=20options=20requ?= =?UTF-8?q?ired?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the user does not give, e.g. an input image, the program just reports a cryptic error message. Fix this and make the CLI friendlier by requiring the options using the Click API. Now the CLI gives a useful error: Error: Missing option '--image' / '-i'. --- qurator/sbb_textline_detector/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qurator/sbb_textline_detector/main.py b/qurator/sbb_textline_detector/main.py index c136e61..341ed7f 100644 --- a/qurator/sbb_textline_detector/main.py +++ b/qurator/sbb_textline_detector/main.py @@ -2160,9 +2160,12 @@ class textline_detector: @click.command() -@click.option('--image', '-i', help='image filename', type=click.Path(exists=True, dir_okay=False)) -@click.option('--out', '-o', help='directory to write output xml data', type=click.Path(exists=True, file_okay=False)) -@click.option('--model', '-m', help='directory of models', type=click.Path(exists=True, file_okay=False)) +@click.option('--image', '-i', help='image filename', + type=click.Path(exists=True, dir_okay=False), required=True) +@click.option('--out', '-o', help='directory to write output xml data', + type=click.Path(exists=True, file_okay=False), required=True) +@click.option('--model', '-m', help='directory of models', + type=click.Path(exists=True, file_okay=False), required=True) def main(image, out, model): possibles = globals() # XXX unused? possibles.update(locals())