-
Notifications
You must be signed in to change notification settings - Fork 36
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
Implement the CLI with Click instead of argparse #297
Comments
@vishav1771 Would you be interested in giving this a shot? |
Sure 👍 |
Awesome, thx! Please feel free to discuss questions about this project directly on this issue. Please apply the "Click" label to any PRs related to this issue so that it is easier for us to keep track of things. |
@vishav1771 Thanks for taking this on! Eventually we will want to do the same for signac-flow, so it may be helpful to document the steps you take along the way for a contributor to do this again for that package. |
To measure coverage of |
I think using pytest-cov is a good idea. We will probably want to use |
I unlinked #300 again, because merging that PR will not fully close this issue. |
I've marked the first two tasks as completed with the merge of #300 . Nice job @vishav1771 ! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Summary
Implement the command line interface (CLI) with the Click library instead of argparse.
Motivation
Using Click for the implementation of a CLI has numerous advantages over using argparse, including a more concise API, the enforcement of a more consistent interface, and built-in support for the implementation of test runners. In addition, the library comes with a collection of helper functions and tools, that are relevant for CLI development. Please see this page for a more comprehensive overview of why one would want to implement a CLI with Click.
Proposed plan for implementation
Since this is a larger refactoring project, it should be executed in stages. Each stage should be introduced as a separate pull request:
signac/__main__.py
is measured, see instructions here.signac/__main_.py
and implement missing tests to reach a test coverage of at least 80%.find
sub-command was successfully refactored, refactor all other sub-commands. Replicate the unit tests for each command found intests/test_shell.py
in a seperate test module calledtests/test_main.py
with Click's built-in test runner. The original tests may not fail!Risks
It is very likely that not all sub-commands can be implemented in the exact same way as before, because Click imposes some restrictions that argparse does not. These restrictions will likely improve the consistency and quality of the CLI, but make it a bit more difficult to create an exact replacement and may require the introduction of some minor backwards incompatibilities.
The text was updated successfully, but these errors were encountered: