maaslalani / confetty

Confetti in your TTY
MIT License
413 stars 18 forks source link

Support Windows #7

Closed mattn closed 3 years ago

mattn commented 3 years ago

Current implementation makes panic on Windows

panic: The handle is invalid.

goroutine 1 [running]:
github.com/maaslalani/confetty/confetti.InitialModel()
    C:/Users/mattn/go/src/github.com/maaslalani/confetty/confetti/confetti.go:65 +0xb2
github.com/maaslalani/confetty/cmd.glob..func1(0x66d780?, {0x50bb18?, 0x0?, 0x0?})
    C:/Users/mattn/go/src/github.com/maaslalani/confetty/cmd/root.go:19 +0x19
github.com/spf13/cobra.(*Command).execute(0x66d780, {0xc000052220, 0x0, 0x0})
    C:/Users/mattn/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0x66d780)
    C:/Users/mattn/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
    C:/Users/mattn/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
github.com/maaslalani/confetty/cmd.Execute()
    C:/Users/mattn/go/src/github.com/maaslalani/confetty/cmd/root.go:50 +0x25
main.main()
    C:/Users/mattn/go/src/github.com/maaslalani/confetty/main.go:8 +0x17

Since the term.GetSize(0) this 0 is not correct value of standard output handle on Windows.

Changes Introduced

This change fixes to pass the correct stdout handle.

screenshot

maaslalani commented 3 years ago

Thank you so much!