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
feat: adding interactive continue printer #384
feat: adding interactive continue printer #384
Conversation
Codecov Report
@@ Coverage Diff @@
## master #384 +/- ##
==========================================
+ Coverage 81.70% 81.77% +0.06%
==========================================
Files 28 29 +1
Lines 2017 2085 +68
==========================================
+ Hits 1648 1705 +57
- Misses 357 365 +8
- Partials 12 15 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
b04ce9d
to
757bc08
Compare
Hi, sorry, we're lacking a bit of a contributing file. You don't have to edit any markdown or SVG files. If you add an example, you only need to commit the I'll review the code later, thanks for the PR! |
oh, ok, do you want me to revert those changes? I generated them with |
Hi @luisdavim, sorry for the delay, I am on vacation since the first August. I didn't have time to look into it before. |
No worries, enjoy your time off, this will be here waiting when you get back 😉 |
Hi @luisdavim, what do you think about adding this as a feature to the confirm printer? I don't really see the benefit in creating a new printer for it, as they would be pretty much the same. |
Sure, I can think about how that would look like. |
757bc08
to
c933b9f
Compare
Hi @MarvinJWendt, sorry for the delay on this. I was thinking about merging this and the confirm printers but I don't think there's a good way, we could replace the confirm printer with this one but that would be a breaking change, the confirm printer returns a func prompt(filename string) (string, error) {
var response string
if _, err := os.Stat(filename); err == nil {
prompt := &survey.Select{
Message: fmt.Sprintf("File %s exists. Overwrite?", filename),
Options: []string{
"diff: show a diff between the current file and the new file",
"yes: overwrite the current file",
"no: do not overwrite the current file",
"all: overwrite all files",
"None: do not overwrite any files",
"quit: exit the program",
},
Filter: func(filterValue string, optValue string, optIndex int) bool {
return strings.HasPrefix(optValue, filterValue)
},
}
err = survey.AskOne(prompt, &response)
return strings.ToLower(strings.Split(response, ":")[0]), err
}
return response, nil
} |
No problem 😉 I'll review the PR soon! |
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.
Hi, could you please make the prompt a little more descriptive? Currently, it's not very clear what the single letters do. Since this is a new printer, we could also accept a map, with the different options. For example map[string]string{"a": "yes to all", "y": "yes", ...}
. A benefit of the map would be, that the keys would definitely be unique then. It would also make up a good reason for a new printer, since there would be a different output too (in comparison with the default confirm printer) 😄
I am thinking about something like:
USER DEFINED TEXT [Y (yes) / n (no) / a (all) / s (stop)]
You could also leave out the options ShowFullHandles
and Handles
then.
Signed-off-by: Luis Davim <luis.davim@sendoso.com>
c933b9f
to
fd5784f
Compare
Yes, that makes sense. A string list is fine then. To the Thanks! |
ok, so, should I revert my last commit and then make the full handles prompt the default? |
This reverts commit df3cbff.
I've updated the PR, it now should the full handles by default and there's an option to display the short version as well. |
Thanks! I'll review the code now :) |
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 have left some comments, some of them can be accepted in bulk directly on GitHub.
Could you also please append the selected value to the prompt, like in the confirm printer?
If you accept the suggestions from GitHub Web, please use the batch feature, otherwise each suggestion would be an own commit 😉
Thanks for the huge PR!
I think I've addressed all your comments. |
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.
LGTM! Thanks for the contribution and your patience! 🚀
I'll have to update the docs website, I'll make the release then!
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/pterm/pterm](https://togithub.com/pterm/pterm) | require | patch | `v0.12.46` -> `v0.12.47` | --- ### Release Notes <details> <summary>pterm/pterm</summary> ### [`v0.12.47`](https://togithub.com/pterm/pterm/releases/tag/v0.12.47) [Compare Source](https://togithub.com/pterm/pterm/compare/v0.12.46...v0.12.47) <!-- Release notes generated using configuration in .github/release.yml at master --> #### What's Changed ##### Exciting New Features 🎉 - feat: adding interactive continue printer by [@​luisdavim](https://togithub.com/luisdavim) in [pterm/pterm#384 ##### Other Changes - bumped go.mod to 1.18 by [@​MarvinJWendt](https://togithub.com/MarvinJWendt) in [pterm/pterm#404 **Full Changelog**: pterm/pterm@v0.12.46...v0.12.47 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/defenseunicorns/zarf). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMDIuNCIsInVwZGF0ZWRJblZlciI6IjMyLjIwMi40In0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/pterm/pterm](https://togithub.com/pterm/pterm) | require | patch | `v0.12.46` -> `v0.12.47` | --- ### Release Notes <details> <summary>pterm/pterm</summary> ### [`v0.12.47`](https://togithub.com/pterm/pterm/releases/tag/v0.12.47) [Compare Source](https://togithub.com/pterm/pterm/compare/v0.12.46...v0.12.47) <!-- Release notes generated using configuration in .github/release.yml at master --> #### What's Changed ##### Exciting New Features 🎉 - feat: adding interactive continue printer by [@​luisdavim](https://togithub.com/luisdavim) in [pterm/pterm#384 ##### Other Changes - bumped go.mod to 1.18 by [@​MarvinJWendt](https://togithub.com/MarvinJWendt) in [pterm/pterm#404 **Full Changelog**: pterm/pterm@v0.12.46...v0.12.47 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/defenseunicorns/zarf). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMDIuNCIsInVwZGF0ZWRJblZlciI6IjMyLjIwMi40In0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Description
Adding a new interactive printer, it's very similar to the confirmation printer but allows for multiple options.
Scope
To-Do Checklist