8000 print grouped common option help in subcommands by reidpr · Pull Request #1394 · hpc/charliecloud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

print grouped common option help in subcommands #1394

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions bin/ch-image.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def main():
# [2]: https://docs.python.org/3/library/argparse.html#parents
# [3]: https://stackoverflow.com/a/54936198
common_opts = \
{ "bucache": [
{ ("bucache", "build cache common options"): [
[["--cache"],
{ "action": "store_const",
"const": ch.Build_Mode.ENABLED,
Expand All @@ -95,7 +95,7 @@ def main():
"const": ch.Build_Mode.REBUILD,
"dest": "bucache",
"help": "force cache misses for non-FROM instructions" }] ],
None: [
(None, "misc common options"): [
[["-a", "--arch"],
{ "metavar": "ARCH",
"default": "host",
Expand Down Expand Up @@ -145,18 +145,17 @@ def main():
p.set_defaults(func=dispatch)
dependencies_check[dispatch] = deps_check
storage_init[dispatch] = stog_init
for (name, group) in common_opts.items():
for ((name, title), group) in common_opts.items():
if (name is None):
p2 = p
p2 = p.add_argument_group(title=title)
else:
p2 = p.add_mutually_exclusive_group()
p2 = p.add_argument_group(title=title)
p2 = p2.add_mutually_exclusive_group()
for (args, kwargs) in group:
if (help_):
kwargs2 = kwargs
else:
kwargs2 = { **kwargs,
"default": argparse.SUPPRESS,
"help": argparse.SUPPRESS }
kwargs2 = { **kwargs, "default": argparse.SUPPRESS }
p2.add_argument(*args, **kwargs2)

# main parser
Expand Down
0