V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
fzdwx
V2EX  ›  分享创造

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

  •  1
     
  •   fzdwx · 2022-08-08 17:15:58 +08:00 · 2185 次点击
    这是一个创建于 620 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这是一个用 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 image

    progress bar image

    confirm image


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

    ![demo]( https://user-images.githubusercontent.com/65269574/183641765-e8de7441-3c4e-4008-b2a9-b2ba556ddd72.gif)
    fzdwx
        6
    fzdwx  
    OP
       2022-08-09 20:03:23 +08:00
    但是在 linux 下运行有个 bug ,会卡住 https://github.com/fzdwx/infinite/issues/5
    beichenshao
        7
    beichenshao  
       2022-08-09 23:27:27 +08:00
    谢谢你让我知道了 bubbletea😂
    fzdwx
        8
    fzdwx  
    OP
       2022-08-10 07:37:56 +08:00
    ......... @beichenshao 老哥试试我的。。。。
    ysicing
        9
    ysicing  
       2022-08-11 18:08:34 +08:00
    fzdwx
        10
    fzdwx  
    OP
       2022-08-11 18:13:58 +08:00
    #9 @ysicing
    我才发现有这么多这种类型的, 以前一个都搜不到。
    yukong
        11
    yukong  
       2022-08-11 20:13:30 +08:00   ❤️ 1
    智齿
    fzdwx
        12
    fzdwx  
    OP
       2022-08-11 20:15:58 +08:00
    #11 @yukong
    可以,感谢大佬!如果有任何疑问欢迎留言。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   927 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:59 · PVG 03:59 · LAX 12:59 · JFK 15:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.