-
-
Notifications
You must be signed in to change notification settings - Fork 301
Add keyboard shortcuts to prompt #406
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
Conversation
I'll add tests later if you like the change. I noticed there wasn't complete approval in #380 yet.
This is great! I like it!
Great, I'll follow up with some tests and docs in the next day or two - and sure I'll drop that chore option. I didn't mean to submit that here, that's just from me fiddling around.
Hey sorry for the delay! I rebased out the chore option, and added a test to ensure all of the options in any select questions in cz_conventional_commits has a keyboard key defined. Actually mocking out and asserting the shortcuts render in the terminal when the config option is enabled was a little too complicated IMO. I also updated the config tests to be aware of the new config option.
Thanks for your update! But might need your help to reformat the code through ./scripts/format
Codecov Report
@@ Coverage Diff @@ ## master #406 +/- ## ======================================= Coverage 97.90% 97.90% ======================================= Files 39 39 Lines 1381 1383 +2 ======================================= + Hits 1352 1354 +2 Misses 29 29
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Docs are updated, and I moved where we check the config for use_shortcuts
to the Commit
class, so that any BaseCommitizen
class automatically gets access to this new feature. Thinking about my team and I, since we like to have chore
included in our custom conventional commits rules.
Also, I mentioned it in the docs, but when there's no key
provided, questionary conveniently falls back to numbering the options. This means that 3rd party templates aren't broken by this new setting! 🎉
eg.; Using the customize settings from the docs with use_shortcuts enabled:
$ poetry run cz commit
? Select the type of change you are committing (Use shortcuts or arrow keys)
» 1) feature: A new feature.
2) bug fix: A bug fix.
didn't expect that handy feature. it's great. let's merge this one!
Description
See the suggestion in #380.
This PR adds a config option called
use_shortcuts
which enables shortcuts in conventional commit choices. It defaults to false, so it'd be opt-in for now. In #380, the suggestion was to add theuse_shortcuts: bool
kwarg to questionary.prompt in commands/commit.py, but questionary passes this on to every question, and subsequently throws for prompt types that don't supportuse_shortcuts
. The solution was to adduse_shortcuts
to the first question in cz/conventional_commits/conventional_commits.py instead.Checklist
./script/format
and./script/test
locally to ensure this change passes linter check and test