summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-12-13 10:29:20 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-12-17 10:44:11 +0100
commit887a2a88791455c494da4afb870eeda385b3f852 (patch)
tree561d7bb8d455b2cf2bb84765e28f63cbbaa90801 /bin
parented16041996102989b47efca70abbc22cbae558fe (diff)
downloadjustbuild-887a2a88791455c494da4afb870eeda385b3f852.tar.gz
just-lock: Improve error handling of command line parsing
Diffstat (limited to 'bin')
-rwxr-xr-xbin/just-lock.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/bin/just-lock.py b/bin/just-lock.py
index a0e7cfe9..8d292ff1 100755
--- a/bin/just-lock.py
+++ b/bin/just-lock.py
@@ -20,7 +20,7 @@ import subprocess
import sys
import tempfile
-from argparse import ArgumentParser
+from argparse import ArgumentParser, ArgumentError
from pathlib import Path
from typing import Any, Dict, List, NoReturn, Optional, Set, Tuple, Union, cast
@@ -888,7 +888,9 @@ def lock_config(input_file: str) -> Json:
def main():
parser = ArgumentParser(
prog="just-lock",
- description="Generate or update a multi-repository configuration file")
+ description="Generate or update a multi-repository configuration file",
+ exit_on_error=False, # catch parsing errors ourselves
+ )
parser.add_argument("-C",
dest="input_file",
help="Input configuration file",
@@ -909,7 +911,12 @@ def main():
dest="launcher",
help="Local launcher to use for commands in imports",
metavar="JSON")
- args = parser.parse_args()
+
+ try:
+ args = parser.parse_args()
+ except ArgumentError as err:
+ fail("Failed parsing command line arguments with:\n%s" %
+ (err.message, ))
# Get the path of the input file
if args.input_file: