Skip to content

Add numbered shortcuts and filter search to Question select/checkbox - #2446

Open
RR5555 wants to merge 24 commits into
copier-org:masterfrom
RR5555:question_filter_shortcut
Open

Add numbered shortcuts and filter search to Question select/checkbox#2446
RR5555 wants to merge 24 commits into
copier-org:masterfrom
RR5555:question_filter_shortcut

Conversation

@RR5555

@RR5555 RR5555 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

PR Description

This PR adds the questionary options use_shortcuts & use_filter_search to Copier Question, to allow the usage of numbered shortcuts for select questions, and filter search for select/checkbox questions.

It addresses Issue #2155

It adds two new attributes to the Question class:

  • use_shortcuts: bool
  • use_filter_search: bool

Which are passed down to questionary, thus producing the desired effect.

Note

use_filter_search is not compatible with use_jk_keys questionary option which is activated by default. Thus, when use_filter_search is True for a select/checkbox question, we pass and put use_jk_keys to False.

Choice

Although, it is possible to pass both {use_filter_search: True, use_shortcuts: True} for select questions, I have decided to make use_filter_search have precedence over use_shortcuts to avoid any ambiguity. Thus, if both are True for a select question, only use_filter_search is passed and activated.

Usage

use_shortcuts

copier.yaml

 select:
     type: str
     help: Select one option only
     use_shortcuts: true
     default: first
     choices:
         one: first
         two: second
         three: third

This will display:

1) one
2) two
3) three

And pressing 3 will direct the cursor onto 3) three .

use_filter_search

copier.yaml

checkbox:
    type: str
    help: Select any
    multiselect: true
    use_filter_search: true
    choices:
        one: first
        two: second
        three: third
        four: fourth

Pressing t will make a field appeared at the bottom left with / t... while only showing:

o two
o three

Next, pressing w will change the bottom field to / tw.. while only showing:

o two

Pressing Backspace will delete the searched letter one at a time, allowing for correction or new/additional filter search.

Limitation

The two new attributes are only booleans, they are not str|bool, and not rendered.

@codecov

codecov Bot commented Jan 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.81%. Comparing base (4e969bf) to head (aa1c05a).
⚠️ Report is 114 commits behind head on master.

Files with missing lines Patch % Lines
copier/_user_data.py 47.05% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2446      +/-   ##
==========================================
- Coverage   97.17%   96.81%   -0.37%     
==========================================
  Files          60       61       +1     
  Lines        7147     7246      +99     
==========================================
+ Hits         6945     7015      +70     
- Misses        202      231      +29     
Flag Coverage Δ
unittests 96.81% <91.00%> (-0.37%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sisp sisp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing these great enhancements of choice questions, @RR5555! 🙏

I have a few inline remarks. And could you please document these settings in the docs?

Comment thread tests/test_choices.py Outdated
Comment thread tests/test_choices.py Outdated
Comment thread tests/test_choices.py Outdated
Comment thread tests/test_choices.py Outdated
Comment thread tests/test_choices.py
Comment thread copier/_user_data.py Outdated
Comment thread copier/_user_data.py Outdated
RR5555 added a commit to RR5555/copier that referenced this pull request Jan 11, 2026
Per reviewer suggestion/request

Reviewed-by: sisp
Refs: copier-org#2446#discussion_r2678784231
Per reviewer suggestion/request

Reviewed-by: sisp
Refs: copier-org#2446#discussion_r2678784231
@RR5555
RR5555 force-pushed the question_filter_shortcut branch from f043dd4 to 08371bf Compare January 11, 2026 06:01
…_filter_search` to `use_search_filter`

Per reviewer catch to match `questionary` args as intended

Reviewed-by: sisp
Refs: copier-org#2446#discussion_r2678785014
Per reviewer request

Reviewed-by: sisp
Refs: copier-org#2446#discussion_r2678786515
Per reviewer suggestion/request
Remove development leftovers

Reviewed-by: sisp
Refs: copier-org#2446#discussion_r2678777344 copier-org#2446#discussion_r2678779566
Per reviewer suggestion/request

Reviewed-by: sisp
Refs: copier-org#2446#discussion_r2678780560
…_filter`

Per reviewer suggestion/request

Reviewed-by: sisp
Refs: copier-org#2446#pullrequestreview-3647014001
@RR5555

RR5555 commented Jan 11, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for reviewing another of my PRs ^^

I had a first go at the documentation of the settings (docs(docs/configuring.md): add docs for use_shortcuts & use_search_filter[f8c695e]).
Please let me know what you think.

RR5555 and others added 2 commits January 12, 2026 19:25
…se_searcg_filter`

Per reviewer suggestion/request

Reviewed-by: sisp
Refs: copier-org#2446#discussion_r2678783429
Comment thread copier/_user_data.py Outdated
Comment thread copier/_user_data.py Outdated
Comment thread docs/configuring.md Outdated
Comment thread docs/configuring.md Outdated
Comment thread docs/configuring.md Outdated
Comment thread docs/configuring.md Outdated
Comment thread docs/configuring.md Outdated
Comment thread tests/test_choices.py
Comment thread docs/configuring.md
Comment thread docs/configuring.md
RR5555 and others added 7 commits March 16, 2026 17:57
…al exclusiveness

Per reviewer request.
Before: `use_search_filter`>`use_shortcuts`
After: ValidationError
Before: `multiselect`>`use_shortcuts`
After: ValidationError

Refs: copier-org#2446#pullrequestreview-3687996014
Per reviewer request.

Refs: copier-org#2446#pullrequestreview-3687996014
…add ValidationError tests

Per reviewer request.

Refs: copier-org#2446#discussion_r2718709082
…se_shortcuts` & `use_search_filter`

Per reviewer request.

Refs: copier-org#2446#pullrequestreview-3687996014
Per reviewer request/suggestion.

Refs: copier-org#2446#pullrequestreview-3687996014
@RR5555

RR5555 commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for your previous round of review. Sorry for the delay.
Please let me know if I have missed something, or if other improvements are required.

@sisp sisp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you! 👍 Just a minor request and a question, then we're ready to merge. 🎉

Comment thread copier/_user_data.py Outdated
Comment thread docs/configuring.md Outdated
@RR5555
RR5555 force-pushed the question_filter_shortcut branch from b75af8f to ddddbea Compare May 5, 2026 05:42
pre-commit hook `rumdl` run by `autofix-ci` would break the output examples contained in the `pre` tags
@RR5555
RR5555 force-pushed the question_filter_shortcut branch from 10ba39b to 38a3954 Compare May 5, 2026 06:28
Follow-up on the previous commit where two additional `pre` blocks were missed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants