- Provides a set of out-of-the-box components
- autocomplete
- progress-bar group
- multi/single select
- spinner
- confirm
- input
- Support window/linux (I only have these two operating systems)
- Customizable (You can replace the implementation of some methods in the component)
- Combinable (You can combine multiple components to use)
autocomplete
is composed ofinput
andselect
select
implements the filter function by embedding theinput
- ...
go get github.com/fzdwx/infinite
code
package main
import (
"github.com/fzdwx/infinite/components"
"github.com/fzdwx/infinite/components/progress"
"time"
)
func main() {
cnt := 10
group := progress.NewGroupWithCount(10).
AppendRunner(func(progress *components.Progress) func() {
total := cnt
cnt += 1
progress.WithTotal(int64(total)).
WithDefaultGradient()
return func() {
for i := 0; i < total+1; i++ {
progress.IncrOne()
sleep()
}
for i := 0; i < total; i++ {
progress.DecrOne()
sleep()
}
for i := 0; i < total+1; i++ {
progress.IncrOne()
sleep()
}
}
})
group.Display()
}
func sleep() {
time.Sleep(time.Millisecond * 100)
}
code
package main
import (
inf "github.com/fzdwx/infinite"
"github.com/fzdwx/infinite/color"
"github.com/fzdwx/infinite/components"
"github.com/fzdwx/infinite/components/selection/multiselect"
"github.com/fzdwx/infinite/style"
)
func main() {
input := components.NewInput()
input.Prompt = "Filtering: "
input.PromptStyle = style.New().Bold().Italic().Fg(color.LightBlue)
_, _ = inf.NewMultiSelect([]string{
"Buy carrots",
"Buy celery",
"Buy kohlrabi",
"Buy computer",
"Buy something",
"Buy car",
"Buy subway",
},
multiselect.WithFilterInput(input),
).Display("select your items!")
}
code
package main
import (
inf "github.com/fzdwx/infinite"
"github.com/fzdwx/infinite/components"
"github.com/fzdwx/infinite/components/spinner"
"time"
)
func main() {
_ = inf.NewSpinner(
spinner.WithShape(components.Dot),
//spinner.WithDisableOutputResult(),
).Display(func(spinner *spinner.Spinner) {
for i := 0; i < 10; i++ {
time.Sleep(time.Millisecond * 100)
spinner.Refreshf("hello world %d", i)
}
spinner.Finish("finish")
spinner.Refresh("is finish?")
})
time.Sleep(time.Millisecond * 100 * 15)
}
code
package main
import (
"fmt"
inf "github.com/fzdwx/infinite"
"github.com/fzdwx/infinite/components/input/text"
"github.com/fzdwx/infinite/theme"
)
func main() {
i := inf.NewText(
text.WithPrompt("what's your name? "),
text.WithPromptStyle(theme.DefaultTheme.PromptStyle),
text.WithPlaceholder(" fzdwx (maybe)"),
)
_ = i.Display()
fmt.Printf("you input: %s\n", i.Value())
}
code
package main
import (
"fmt"
inf "github.com/fzdwx/infinite"
"github.com/fzdwx/infinite/components/input/confirm"
)
func main() {
c := inf.NewConfirm(
confirm.WithDefaultYes(),
confirm.WithDisplayHelp(),
)
c.Display()
if c.Value() {
fmt.Println("yes, you are.")
} else {
fmt.Println("no,you are not.")
}
}
- https://github.com/charmbracelet/bubbletea
- https://github.com/charmbracelet/bubbles
- https://github.com/charmbracelet/lipgloss
- https://github.com/muesli/termenv
- https://github.com/sahilm/fuzzy
- ...
MIT