Closed dn-scribe closed 5 months ago
In cases where there in an hierarchy of commands, and use of envs - either by default_env=True or by using `export JSONARGPARSE_DEFAULT_ENV=true', parsing fails. Here is an example:
default_env=True
from jsonargparse import CLI,ArgumentParser, ActionConfigFile parser = ArgumentParser(description="CLI tool for discovering assets on Dockerhub", default_env=True) parser.add_argument('--config', action=ActionConfigFile) a_parser = ArgumentParser() a_parser.add_argument('--a_arg', default='a_arg', help='A argument') b_parser = ArgumentParser() b_parser.add_argument('--b_arg', default='b_arg', help='B argument') c_parser = ArgumentParser() c_parser.add_argument('--c_arg', default='c_arg', help='C argument') subcommands = parser.add_subcommands() subcommands.add_subcommand('a', a_parser) subcommands.add_subcommand('c', c_parser) a_subs = a_parser.add_subcommands() a_subs.add_subcommand('sub', b_parser) args = parser.parse_args() print(args)
Running:
python a.py a sub usage: a.py [options] a [-h] [--a_arg A_ARG] {sub} ... error: expected "subcommand" to be one of {sub}, but it was not provided.
When disabling both environment options (env and code) it works fine:
export JSONARGPARSE_DEFAULT_ENV=false āÆ python a.py a sub Namespace(config=None, subcommand='a', a=Namespace(a_arg='a_arg', subcommand='sub', sub=Namespace(b_arg='b_arg')))
See above.
Succeed in parsing.
pip install jsonargparse[all]
@dn-scribe thank you for reporting! This should be fixed with #466.
š Bug report
In cases where there in an hierarchy of commands, and use of envs - either by
default_env=True
or by using `export JSONARGPARSE_DEFAULT_ENV=true', parsing fails. Here is an example:Running:
When disabling both environment options (env and code) it works fine:
To reproduce
See above.
Expected behavior
Succeed in parsing.
Environment
pip install jsonargparse[all]
): `pip install jsonargparse'