diff options
Diffstat (limited to 'bin/utils/cmd_line.py')
-rw-r--r-- | bin/utils/cmd_line.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/utils/cmd_line.py b/bin/utils/cmd_line.py new file mode 100644 index 0000000..6bfeafe --- /dev/null +++ b/bin/utils/cmd_line.py @@ -0,0 +1,15 @@ +# Copyright 2016 (c) Egor Tensin <Egor.Tensin@gmail.com> +# This file is part of the "Simple image filters" project. +# For details, see https://github.com/egor-tensin/filters. +# Distributed under the MIT License. + +import argparse + +def parse_non_negative_integer(s): + try: + x = int(s) + except ValueError: + raise argparse.ArgumentTypeError('must be a non-negative integer: ' + s) + if x < 0: + raise argparse.ArgumentTypeError('must be a non-negative integer: ' + s) + return x |