From b84286970f6eb6ef879dd59f89b1826b3aa6bb46 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 11 Dec 2019 14:07:31 +0100 Subject: [PATCH] Error if -t is specified multiple times. --- cdist | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cdist b/cdist index 8a1b3c4..e5af8f5 100755 --- a/cdist +++ b/cdist @@ -1014,7 +1014,7 @@ def main(): parser.add_argument('-c', '--checkout', help='string to pass to git for checkout') parser.add_argument('-o', '--output', help='output directory', default='.') parser.add_argument('-q', '--quiet', help='be quiet', action='store_true') - parser.add_argument('-t', '--target', help='target') + parser.add_argument('-t', '--target', help='target', action='append') parser.add_argument('-k', '--keep', help='keep working tree', action='store_true') parser.add_argument('--debug', help='build with debugging symbols where possible', action='store_true') parser.add_argument('-w', '--work', help='override default work directory') @@ -1028,6 +1028,14 @@ def main(): parser.add_argument('--ccache', help='use ccache', action='store_true') args = parser.parse_args() + # Check for incorrect multiple parameters + if args.target is not None: + if len(args.target) > 1: + parser.error('multiple -t options specified') + sys.exit(1) + else: + args.target = args.target[0] + # Override configured stuff if args.git_prefix is not None: config.set('git_prefix', args.git_prefix) -- 2.30.2