From 2bfaa4a196af9c935e5140beee7e52ea189b6632 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 16 Sep 2026 10:07:20 +0500 Subject: [PATCH] build-all: `--help` to include default values --- nix/build-all.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nix/build-all.py b/nix/build-all.py index faca5acc6d..b384759a74 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -198,6 +198,13 @@ xz = "xz" # Used implicitly for `tar -xf *.tar.xz`. brew = "brew" +class ArgFormatter(argparse.RawDescriptionHelpFormatter, argparse.ArgumentDefaultsHelpFormatter): + """ + `RawDescriptionHelpFormatter`needed to keep epilog's manual formatting. + Default formatter collapses whitespaces. + """ + + class Args(NamedTuple): explicit_targets: list[str] build_examples: bool @@ -249,7 +256,7 @@ class DynamicArgs(NamedTuple): def parse_args() -> tuple[Args, DynamicArgs]: arg_parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter, + formatter_class=ArgFormatter, epilog=textwrap.dedent("""\ Additional dynamic -flags (not declared above): -py-313 build for specific Python version @@ -257,7 +264,7 @@ def parse_args() -> tuple[Args, DynamicArgs]: -occt-xxx use a specific OCCT version (e.g. -occt-7.8.1) instead of the default -without-xxx do not build dependency `xxx` (e.g. --without-swig)"""), ) - arg_parser.add_argument("explicit_targets", nargs="*", help="Targets provided by CLI.") + arg_parser.add_argument("explicit_targets", nargs="*", default=[], help="Targets provided by CLI.") arg_parser.add_argument( "--build-examples", action="store_true",