Skip to content

Commit 710d533

Browse files
committed
add --help-all support
a bit funky, since we are combining two separate parsers
1 parent 885cb46 commit 710d533

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

repo2docker/__main__.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ def get_argparser():
6666
description="Fetch a repository and build a container image"
6767
)
6868

69+
argparser.add_argument(
70+
"--help-all",
71+
dest="help_all",
72+
action="store_true",
73+
help="Display all configurable options and exit.",
74+
)
75+
76+
argparser.add_argument(
77+
"--version",
78+
dest="version",
79+
action="store_true",
80+
help="Print the repo2docker version and exit.",
81+
)
82+
6983
argparser.add_argument(
7084
"--config",
7185
default="repo2docker_config.py",
@@ -222,13 +236,6 @@ def get_argparser():
222236

223237
argparser.add_argument("--subdir", type=str, help=Repo2Docker.subdir.help)
224238

225-
argparser.add_argument(
226-
"--version",
227-
dest="version",
228-
action="store_true",
229-
help="Print the repo2docker version and exit.",
230-
)
231-
232239
argparser.add_argument(
233240
"--cache-from", action="append", default=[], help=Repo2Docker.cache_from.help
234241
)
@@ -245,13 +252,21 @@ def make_r2d(argv=None):
245252
if argv is None:
246253
argv = sys.argv[1:]
247254

255+
argparser = get_argparser()
256+
248257
# version must be checked before parse, as repo/cmd are required and
249258
# will spit out an error if allowed to be parsed first.
250259
if "--version" in argv:
251260
print(__version__)
252261
sys.exit(0)
253262

254-
args, traitlet_args = get_argparser().parse_known_args(argv)
263+
if "--help-all" in argv:
264+
argparser.print_help()
265+
print("\nAll configurable options:\n")
266+
Repo2Docker().print_help(classes=True)
267+
sys.exit(0)
268+
269+
args, traitlet_args = argparser.parse_known_args(argv)
255270

256271
r2d = Repo2Docker()
257272
r2d.parse_command_line(traitlet_args)

repo2docker/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class Repo2Docker(Application):
4747
name = "jupyter-repo2docker"
4848
version = __version__
4949
description = __doc__
50+
# disable aliases/flags because we don't use the traitlets for CLI parsing
51+
# other than --Class.trait=value
52+
aliases = {}
53+
flags = {}
5054

5155
@default("log_level")
5256
def _default_log_level(self):

0 commit comments

Comments
 (0)