-
Notifications
You must be signed in to change notification settings - Fork 17
ENH: Add command to CLI to generate config file, fix #366 #809
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
Open
NickleDave
wants to merge
37
commits into
main
Choose a base branch
from
ENH-add-cli-command-configfile-fix-#366
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To add a `configfile` command, we can no longer assume that we have just two arguments, `command` and `configfile`. Instead we need to move to sub-parsers, even though must of the sub-parsers will just be the same named commands as before, and will only have a single positional argument of `configfile`. As of now, only the new `configfile` command will be different, although I haven't figured out what its args will be yet. To do this I ended up representing cli commands as a dataclass inside the `vak.cli.cli` module, with attributes `name`, `help`, `func`, and `add_parser_args_func`. I am choosing to send each sub-parser to `dest='command'`, and then dispatching based on the value of `command` inside the `vak.cli.cli.cli` function, instead of letting `argparse` do all the work, because I want to be able to raise a somewhat friendly error message. Maybe this is not needed since argparse validates arguments anyways. But this requires the least rewiring of what we already had in place.
…itle+description so we get more info from parser.print_help
… typehints args parameter as arpgarse.Namespace, and spell out pathlib.Path instead of importing Path from pathlib
…test that calling 'vak' without args results in parser.print_help()
…oupled with implementation details
… sure it is .toml
…rror when dst is a path to a file but extension is not '.toml'
…orter vak.config.generate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.