Use argparse only if name is main, call main with args dict
Description
Working on the tests, mildly annoyed by way the webservice uses argparse and how it's started so I changed it a bit:
- Adjusted some of the command line argument names and variable names so that they match
- Argparse setup is only done if
webservice.py
is called by python (if __name__ == "__main__"
) - Changed the
main
function to take in keyword arguments - Splat argparse args dict into main if called by python
NOTE: --logging
has changed to --log-level
How Has This Been Tested?
Not at all
Called it manually with some print stuff:
❯ python3 ./webservice/webservice.py --log-level DEBUG
{'config_file': './webservice.yaml', 'mode': 'sim', 'log_file': './web.log', 'log_level': 'DEBUG'}
./webservice.yaml sim ./web.log DEBUG
Seems to work.
Relevant Documents (optional)
N/A
Types of changes
- Style (formatting changes only, no code changes)
- Refactor (refactoring code with no functionality changes)
Checklist:
- My code follows the code style of this project.
Reviewers
Edited by Robert Rosca