[8/N] enable cli flag without a space (#10529)

Signed-off-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
youkaichao
2024-11-21 12:30:42 -08:00
committed by GitHub
parent e7a8341c7c
commit 7560ae5caf
5 changed files with 43 additions and 7 deletions

View File

@@ -1192,6 +1192,10 @@ class FlexibleArgumentParser(argparse.ArgumentParser):
else:
processed_args.append('--' +
arg[len('--'):].replace('_', '-'))
elif arg.startswith('-O') and arg != '-O' and len(arg) == 2:
# allow -O flag to be used without space, e.g. -O3
processed_args.append('-O')
processed_args.append(arg[2:])
else:
processed_args.append(arg)