Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(doc): add commentary on default parser #715

Merged
merged 4 commits into from
Apr 25, 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
10 changes: 10 additions & 0 deletions universum/lib/module_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ def _needs_default_parser(subparsers_action, args):
return True

def _add_default_parser(self, args):
"""
We need to manually add the default parser because of subcommand's arguments intersection.
1. We need subcommands for namespaces and help messages to be ajustable in different Universum modes.
2. If a subcommand is passed, and arguments in parser and subparser intersect, all values passed to
non-subparser are ignored; so without default subparser ``universum -vt=p4 submit`` will result in
undefined value of 'vcs_type', and ``universum -vt=p4 submit -vt=git`` will result in 'git' value.
Adding default subparser allows to avoid such unexpected behaviour.
3. Also if arguments of 'general' parser and a subparser intersect, the environment variables are
stored to 'general' parser (and then ignored as described above).
"""
subparsers_action = self._get_subparsers_action()
if not subparsers_action:
return
Expand Down