darjun / go-daily-lib

Go 每日一库
5.09k stars 606 forks source link

用Golang开发的交互式命令行组件库 #59

Open fzdwx opened 2 years ago

fzdwx commented 2 years ago

推荐项目

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!")

}


- 截图:

autocomplete:
![demo](https://user-images.githubusercontent.com/65269574/183641765-e8de7441-3c4e-4008-b2a9-b2ba556ddd72.gif)

print
![demo](https://user-images.githubusercontent.com/65269574/184350545-01c52f90-77a1-42c3-9bb0-7c23b828799a.gif)

multi select
![image](https://user-images.githubusercontent.com/65269574/183274216-d2a7af91-0581-4d13-b8c2-00b9aad5ef3a.gif)

progress bar
![image](https://user-images.githubusercontent.com/65269574/183296585-b0a56827-d9d9-4258-ad32-266ada01b1ed.gif)

confirm
![image](https://user-images.githubusercontent.com/65269574/183076452-5fa73013-42de-47df-97b4-7be743d074c1.gif)