GithubHelp home page GithubHelp logo

Comments (5)

tetienne-zenchef avatar tetienne-zenchef commented on September 26, 2024 3

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.

vitor-mariano avatar vitor-mariano commented on September 26, 2024

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!")

demo

from huh.

maaslalani avatar maaslalani commented on September 26, 2024

Hey @tetienne @tetienne-zenchef! Thanks for creating this issue, is this issue still required for you or is the workaround sufficient?

from huh.

tetienne-zenchef avatar tetienne-zenchef commented on September 26, 2024

@maaslalani This workaround is enough now I understand the philosophy behind huh and its form. Thx.

from huh.

maaslalani avatar maaslalani commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.