Comments (5)
Thx for your answer. To be honest, I didn’t try the form part. See here for the why.
Now I did it, I got your point.
I was able to implement what I asked for thx to your help:
prompt := huh.NewInput().
Value(&name).
Title("Enter the name of the parameter to set")
cobra.CheckErr(prompt.Run())
fmt.Println(prompt.View())
from huh.
I think the problem with persisting the answers is that the user can move back and forth in groups. When this is not the case, you can easily achieve the same behavior by printing the group view as in the example below.
orderGroup := huh.NewGroup(
huh.NewMultiSelect[string]().
Title("Toppings").
Options(
huh.NewOptions("Letuce", "Tomatoes", "Jalapeños", "Cheese", "Vegan Cheese", "Nutella")...,
).
Value(&a.Toppings),
huh.NewConfirm().Title("Extra sauce?").Value(&a.ExtraSauce),
)
form := huh.NewForm(orderGroup)
err := form.Run()
if err != nil {
panic(err)
}
fmt.Println(orderGroup.WithShowHelp(false).View())
fmt.Println("Thank you for your order!")
from huh.
Hey @tetienne @tetienne-zenchef! Thanks for creating this issue, is this issue still required for you or is the workaround sufficient?
from huh.
@maaslalani This workaround is enough now I understand the philosophy behind huh and its form. Thx.
from huh.
Awesome @tetienne-zenchef! I'm going to close this issue for now, but please feel free to re-open or create a new issue if anything comes up!
from huh.
Related Issues (20)
- For Single or Multiple Select, Support Circular Selection
- build stacktrace because `huh` uses refactored `x/exp/term` HOT 1
- Confirm box default to Yes HOT 2
- Confirm button indent at wrong position HOT 3
- FR: Fuzzy find for file picker and select
- Preceding a confirm dialog with a spinner causes the first input keystroke to be ignored HOT 2
- v0.5.0 broke withHide function
- Don't render title row when title is empty
- Feature Request: Validate on a Group
- v0.5.3 breaks Select.Title when options don't fit on the screen
- Allow Cursor option for the filepicker HOT 1
- Looking for help with some issues HOT 2
- `huh.Text`, ^e, open in `$EDITOR`, and Emacs keybindings HOT 1
- Column layout does not show "next" columns after first "screen"
- huh.NewConfirm() proceeds even with validation error
- large title in huh.NewConfirm() breaking alignment HOT 1
- Dynamic fields sometimes don't render when initially switching to a new group
- FR: Enhance FilePicker UX for directory mode
- Focus not given to first field when redirected to a huh.Form from a tea.Model HOT 2
- Shift+Tab doesn't go to previous field if Select OptionsFunc returns no options
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from huh.