Skip to content

Commit 012df6b

Browse files
committed
remote/client: sphinx-argparse 0.5.2 workarounds
Hide intentionally undocumented subcommands and overlong lists of choices. PRs to fix the ineffective @Skip we have for those sections and to display ranges properly are open and these workarounds should be removed once the fixes made it into a release. Signed-off-by: Jonas Rebmann <[email protected]>
1 parent edc7597 commit 012df6b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

labgrid/remote/client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ def __str__(self):
17051705
return self.value
17061706

17071707

1708-
def get_parser() -> argparse.ArgumentParser:
1708+
def get_parser(include_undocumented=False) -> argparse.ArgumentParser:
17091709
parser = argparse.ArgumentParser()
17101710
parser.add_argument(
17111711
"-x",
@@ -1744,11 +1744,12 @@ def get_parser() -> argparse.ArgumentParser:
17441744
metavar="COMMAND",
17451745
)
17461746

1747-
subparser = subparsers.add_parser("help")
1747+
if include_undocumented:
1748+
subparser = subparsers.add_parser("help")
17481749

1749-
subparser = subparsers.add_parser("complete")
1750-
subparser.add_argument("type", choices=["resources", "places", "matches", "match-names"])
1751-
subparser.set_defaults(func=ClientSession.complete)
1750+
subparser = subparsers.add_parser("complete")
1751+
subparser.add_argument("type", choices=["resources", "places", "matches", "match-names"])
1752+
subparser.set_defaults(func=ClientSession.complete)
17521753

17531754
subparser = subparsers.add_parser("monitor", help="monitor events from the coordinator")
17541755
subparser.set_defaults(func=ClientSession.do_monitor)
@@ -1997,7 +1998,7 @@ def get_parser() -> argparse.ArgumentParser:
19971998
"-p",
19981999
"--partition",
19992000
type=int,
2000-
choices=range(0, 256),
2001+
choices=(range(0, 256) if include_undocumented else None),
20012002
metavar="0-255",
20022003
default=1,
20032004
help="partition number to mount or 0 to mount whole disk (default: %(default)s)",
@@ -2091,7 +2092,7 @@ def main():
20912092
initial_state = os.environ.get("LG_INITIAL_STATE", None)
20922093
token = os.environ.get("LG_TOKEN", None)
20932094

2094-
parser = get_parser()
2095+
parser = get_parser(include_undocumented=True)
20952096

20962097
# make any leftover arguments available for some commands
20972098
args, leftover = parser.parse_known_args()

0 commit comments

Comments
 (0)