Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The main goal for this refactoring is to co-locate all code responsible for each command. Currently, such code is spread across 3 places: * parser configuration in `parser.py`; * implementation in `cli.py`; * name-to-code mapping in `__main__.py`. This patch combines all three aspects of each command in a single class following a common protocol. This makes it easier to add/modify commands. In addition, I made the following changes: * Moved most code into an `_internal` package, to discourage external code from using it. * Split off some code into dedicated modules. * Added a `CommandGroup` class that itself implements the `Command` protocol. This makes it possible to implement command hierarchies in the future. * Redid the somewhat hacky way in which the code determined which options to pass to the command implementation. Now we pop all common options when we process them, which means all remaining options belong to the command. I had to mark some of the `create` options with `default=argparse.SUPPRESS` to make this work. * Replaced the descriptions for some of the commands with the docstring of the implementation functions, which had more details. Removed the docstrings themselves, which were redundant. * Removed the `RawTextHelpFormatter` from the `create` argument parser, to ensure consistent help formatting between commands. Adjusted the `--filename_pattern` option description to compensate. * Cleaned up the signatures of implementation functions: made all parameters except the client kw-only, removed default values (which would never be used), removed parameters that didn't correspond to any command-line options, fixed some parameter types. Other than the command description updates, none of the changes here should affect the external behavior of the CLI.
- Loading branch information