X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=config.py;h=c7c686d738803484a6ae6277af7fc5ebd25d5056;hb=562a15c6397610cf93646d9530005eb4a0d6e6f8;hp=c5813a81145764c05d7af29ce32a07da4ef36ef8;hpb=1e858172519e9339e4720b8bf9b39b6d9801e305;p=python_utils.git diff --git a/config.py b/config.py index c5813a8..c7c686d 100644 --- a/config.py +++ b/config.py @@ -41,7 +41,20 @@ Usage: If you set this up and remember to invoke config.parse(), all commandline arguments will play nicely together. This is done automatically for you - if you're using the bootstrap module's initialize wrapper.:: + if you're using the :meth:`bootstrap.initialize` decorator on + your program's entry point. See :meth:`python_modules.bootstrap.initialize` + for more details.:: + + import bootstrap + + @bootstrap.initialize + def main(): + whatever + + if __name__ == '__main__': + main() + + Either way, you'll get this behavior from the commandline:: % main.py -h usage: main.py [-h] @@ -241,6 +254,19 @@ def _reorder_arg_action_groups_before_help(entry_module: Optional[str]): return reordered_action_groups +def print_usage() -> None: + """Prints the normal help usage message out.""" + ARGS.print_help() + + +def usage() -> str: + """ + Returns: + program usage help text as a string. + """ + return ARGS.format_usage() + + def _augment_sys_argv_from_environment_variables(): """Internal. Look at the system environment for variables that match arg names. This is done via some munging such that: @@ -256,7 +282,7 @@ def _augment_sys_argv_from_environment_variables(): """ - usage_message = ARGS.format_usage() + usage_message = usage() optional = False var = '' for x in usage_message.split():