Skip to content
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!: v2 #423

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,10 @@ func NewModel() Model {
}
}

func (m Model) Init() tea.Cmd {
return m.form.Init()
func (m Model) Init() (tea.Model, tea.Cmd) {
form, cmd := m.form.Init()
m.form = form.(*huh.Form)
return m, cmd
}

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
Expand Down Expand Up @@ -470,14 +472,14 @@ Tea example][example].
[example]: https://github.com/charmbracelet/huh/blob/main/examples/bubbletea/main.go

## `Huh?` in the Wild
For some `Huh?` programs in production, see:

* [glyphs](https://github.com/maaslalani/glyphs): a unicode symbol picker
* [meteor](https://github.com/stefanlogue/meteor): a highly customisable conventional commit message tool
* [freeze](https://github.com/charmbracelet/freeze): a tool for generating images of code and terminal output
* [gum](https://github.com/charmbracelet/gum): a tool for glamorous shell scripts
* [savvy](https://github.com/getsavvyinc/savvy-cli): the easiest way to create, share, and run runbooks in the terminal
For some `Huh?` programs in production, see:

- [glyphs](https://github.com/maaslalani/glyphs): a unicode symbol picker
- [meteor](https://github.com/stefanlogue/meteor): a highly customisable conventional commit message tool
- [freeze](https://github.com/charmbracelet/freeze): a tool for generating images of code and terminal output
- [gum](https://github.com/charmbracelet/gum): a tool for glamorous shell scripts
- [savvy](https://github.com/getsavvyinc/savvy-cli): the easiest way to create, share, and run runbooks in the terminal

## Feedback

Expand Down
2 changes: 1 addition & 1 deletion examples/accessibility/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"log"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
10 changes: 6 additions & 4 deletions examples/bubbletea/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"
"strings"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/huh"
tea "github.com/charmbracelet/bubbletea/v2"
"github.com/charmbracelet/huh/v2"
"github.com/charmbracelet/lipgloss"
)

Expand Down Expand Up @@ -106,8 +106,10 @@ func NewModel() Model {
return m
}

func (m Model) Init() tea.Cmd {
return m.form.Init()
func (m Model) Init() (tea.Model, tea.Cmd) {
form, cmd := m.form.Init()
m.form = form.(*huh.Form)
return m, cmd
}

func min(x, y int) int {
Expand Down
4 changes: 2 additions & 2 deletions examples/burger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strings"
"time"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/spinner"
"github.com/charmbracelet/huh/v2"
"github.com/charmbracelet/huh/v2/spinner"
"github.com/charmbracelet/lipgloss"
xstrings "github.com/charmbracelet/x/exp/strings"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/conditional/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

type consumable int
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic/dynamic-all/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"strconv"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic/dynamic-count/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strconv"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic/dynamic-country/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/charmbracelet/log"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic/dynamic-increment/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic/dynamic-markdown/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"

"github.com/charmbracelet/glamour"
"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic/dynamic-name/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/dynamic/dynamic-suggestions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"log"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/spinner"
"github.com/charmbracelet/huh/v2"
"github.com/charmbracelet/huh/v2/spinner"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/filepicker/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/gh/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"os"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/spinner"
"github.com/charmbracelet/huh/v2"
"github.com/charmbracelet/huh/v2/spinner"
"github.com/charmbracelet/lipgloss"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/git/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

// types is the possible commit types specified by the conventional commit spec.
Expand Down
14 changes: 8 additions & 6 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module examples
go 1.22

require (
github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea v1.1.1
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.1
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1
github.com/charmbracelet/glamour v0.8.0
github.com/charmbracelet/huh v0.0.0-00010101000000-000000000000
github.com/charmbracelet/huh/spinner v0.0.0-00010101000000-000000000000
github.com/charmbracelet/huh/v2 v2.0.0-00010101000000-000000000000
github.com/charmbracelet/huh/v2/spinner v0.0.0-00010101000000-000000000000
github.com/charmbracelet/lipgloss v0.13.0
github.com/charmbracelet/log v0.4.0
github.com/charmbracelet/ssh v0.0.0-20240725163421-eb71b85b27aa
Expand All @@ -22,6 +22,7 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/catppuccin/go v0.2.0 // indirect
github.com/charmbracelet/bubbletea v1.1.1 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/keygen v0.5.1 // indirect
github.com/charmbracelet/x/ansi v0.3.2 // indirect
Expand All @@ -30,6 +31,7 @@ require (
github.com/charmbracelet/x/input v0.2.0 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/charmbracelet/x/termios v0.1.0 // indirect
github.com/charmbracelet/x/windows v0.2.0 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
Expand Down Expand Up @@ -59,6 +61,6 @@ require (
golang.org/x/text v0.18.0 // indirect
)

replace github.com/charmbracelet/huh => ../
replace github.com/charmbracelet/huh/v2 => ../

replace github.com/charmbracelet/huh/spinner => ../spinner
replace github.com/charmbracelet/huh/v2/spinner => ../spinner
8 changes: 6 additions & 2 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA=
github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.1 h1:4Am/U9zvRBZ5iSIDeNioGrc9N9+4U2AjiRJBttAwUVc=
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.1/go.mod h1:rq09SZbh77FFBMvKi5k2vGXJ7K4u0GjLqmUby3K3los=
github.com/charmbracelet/bubbletea v1.1.1 h1:KJ2/DnmpfqFtDNVTvYZ6zpPFL9iRCRr0qqKOCvppbPY=
github.com/charmbracelet/bubbletea v1.1.1/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1 h1:OZtpLCsuuPplC+1oyUo+/eAN7e9MC2UyZWKlKrVlUnw=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1/go.mod h1:j0gn4ft5CE7NDYNZjAA3hBM8t2OPjI8urxuAD0oR4w8=
github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs=
github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
Expand Down Expand Up @@ -52,6 +54,8 @@ github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4h
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
github.com/charmbracelet/x/termios v0.1.0 h1:y4rjAHeFksBAfGbkRDmVinMg7x7DELIGAFbdNvxg97k=
github.com/charmbracelet/x/termios v0.1.0/go.mod h1:H/EVv/KRnrYjz+fCYa9bsKdqF3S8ouDK0AZEbG7r+/U=
github.com/charmbracelet/x/windows v0.2.0 h1:ilXA1GJjTNkgOm94CLPeSz7rar54jtFatdmoiONPuEw=
github.com/charmbracelet/x/windows v0.2.0/go.mod h1:ZibNFR49ZFqCXgP76sYanisxRyC+EYrBE7TTknD8s1s=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
2 changes: 1 addition & 1 deletion examples/gum/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/help/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
f := huh.NewForm(
Expand Down
2 changes: 1 addition & 1 deletion examples/hide/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/layout/columns/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
form := huh.NewForm(
Expand Down
2 changes: 1 addition & 1 deletion examples/layout/default/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
form := huh.NewForm(
Expand Down
2 changes: 1 addition & 1 deletion examples/layout/grid/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
form := huh.NewForm(
Expand Down
2 changes: 1 addition & 1 deletion examples/layout/stack/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
form := huh.NewForm(
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple-groups/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/confirm/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/input/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func isFood(_ string) error {
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"log"

"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

// TODO: ensure input is not plagiarized.
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/multiselect/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
var toppings []string
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/note/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
note := huh.NewNote().Description(
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/select/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
var country string
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/select/scroll/scroll.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

type Pokemon struct {
id int
Expand Down
2 changes: 1 addition & 1 deletion examples/readme/text/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

// TODO: ensure input is not plagiarized.
func checkForPlagiarism(s string) error { return nil }
Expand Down
2 changes: 1 addition & 1 deletion examples/scroll/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/charmbracelet/huh"
import "github.com/charmbracelet/huh/v2"

func main() {
form := huh.NewForm(
Expand Down
2 changes: 1 addition & 1 deletion examples/skip/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/charmbracelet/huh"
"github.com/charmbracelet/huh/v2"
)

func main() {
Expand Down
Loading
Loading