diff options
| author | Scott Gasch <[email protected]> | 2021-07-16 21:43:44 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2021-07-16 21:43:44 -0700 |
| commit | 1574e8a3a8982fab9278ad534f9427d464e4bffb (patch) | |
| tree | ec6e6428ce43f2af64598f2023de3f7d784c5fe3 /config.py | |
| parent | 0e451d3b3bf899b3d9ac0c38e3c3cd9d9be170ba (diff) | |
Various
Diffstat (limited to 'config.py')
| -rw-r--r-- | config.py | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -69,7 +69,7 @@ import os import pprint import re import sys -from typing import Any, Dict, List +from typing import Any, Dict, List, Optional # This module is commonly used by others in here and should avoid # taking any unnecessary dependencies back on them. @@ -157,7 +157,7 @@ def is_flag_already_in_argv(var: str): return False -def parse(entry_module: str) -> Dict[str, Any]: +def parse(entry_module: Optional[str]) -> Dict[str, Any]: """Main program should call this early in main()""" global config_parse_called if config_parse_called: @@ -166,17 +166,19 @@ def parse(entry_module: str) -> Dict[str, Any]: global saved_messages # If we're about to do the usage message dump, put the main module's - # argument group first in the list, please. + # argument group first in the list (if possible), please. reordered_action_groups = [] prog = sys.argv[0] + for arg in sys.argv: if arg == '--help' or arg == '-h': - print(entry_module) for group in args._action_groups: - if entry_module in group.title or prog in group.title: - reordered_action_groups.insert(0, group) + if entry_module is not None and entry_module in group.title: + reordered_action_groups.insert(0, group) # prepend + elif prog in group.title: + reordered_action_groups.insert(0, group) # prepend else: - reordered_action_groups.append(group) + reordered_action_groups.append(group) # append args._action_groups = reordered_action_groups # Examine the environment variables to settings that match |
