用 Golang 写的 tui(终端、命令行)组件库,比如 progress, progress group, select, confirm...

2022-08-08 17:15:58 +08:00
 fzdwx

这是一个用 Golang 开发的交互式命令行组件库,它提供了一些常用的交互式组件,比如说progress,progress group,mulit select,input text,confirm等.同时也提供了一些更基础的组件,方便用户进行组合使用。

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.WithHintSymbol("x"),
		multiselect.WithUnHintSymbol("√"),
		multiselect.WithFilterInput(input),
	).Display("select your items!")
}

multi select

progress bar

confirm


2207 次点击
所在节点    分享创造
12 条回复
hsfzxjy
2022-08-08 17:58:15 +08:00
和 bubbletea 比有什么亮点吗
fzdwx
2022-08-08 18:05:57 +08:00
@hsfzxjy #1
就是用 bubbletea 写的,就是 bubbles 里面的 model 都不能直接使用,所以我就写了这个。
misaka19000
2022-08-08 18:07:05 +08:00
资瓷
fzdwx
2022-08-08 19:00:38 +08:00
各位大佬们可以给点建议。。。
fzdwx
2022-08-09 20:02:44 +08:00
今天新添加一个组件: autocomplete (自动完成)

![demo]( https://user-images.githubusercontent.com/65269574/183641765-e8de7441-3c4e-4008-b2a9-b2ba556ddd72.gif)
fzdwx
2022-08-09 20:03:23 +08:00
但是在 linux 下运行有个 bug ,会卡住 https://github.com/fzdwx/infinite/issues/5
beichenshao
2022-08-09 23:27:27 +08:00
谢谢你让我知道了 bubbletea😂
fzdwx
2022-08-10 07:37:56 +08:00
......... @beichenshao 老哥试试我的。。。。
ysicing
2022-08-11 18:08:34 +08:00
fzdwx
2022-08-11 18:13:58 +08:00
#9 @ysicing
我才发现有这么多这种类型的, 以前一个都搜不到。
yukong
2022-08-11 20:13:30 +08:00
智齿
fzdwx
2022-08-11 20:15:58 +08:00
#11 @yukong
可以,感谢大佬!如果有任何疑问欢迎留言。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/871471

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX