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
Make lists searchable and add key mapping to README.md #20
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20 +/- ##
==========================================
- Coverage 32.40% 31.01% -1.39%
==========================================
Files 5 5
Lines 179 187 +8
==========================================
Hits 58 58
- Misses 109 117 +8
Partials 12 12
Continue to review full report at Codecov.
|
@@ -16,7 +16,16 @@ func prompt(sources map[Resource]bool, destinations map[Resource]bool) (Resource | |||
Selected: "{{ .Address }}", | |||
} | |||
srcs := toSlice(sources) | |||
prompt := promptui.Select{Label: "Select Source", Items: append(srcs, Resource{"Finished", "no more resources to move"}), Templates: srcTempl} | |||
srcSearcher := func(input string, index int) bool { | |||
if index >= len(srcs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand https://github.com/manifoldco/promptui/blob/master/list/list.go#L82 correctly, this check might be a bit defensive - what do you think?
If we need it here, should we also add a corresponding check in destSearcher
below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need it because of the additional Resource{"Finished", "no more resources to move"}
item that's added to the end of the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for the explanation!
Great idea, thank you very much for the contribution! |
Has been released in 0.4.0. |
This PR enables the search functionality of promptui.Select.
strings.Contains(address, searchTerm)
.README.md
.