百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

boa

> 编程语言
开源

由 bubbletea 提供的 Cobra 命令风格的使用和帮助组件

200 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

由 bubbletea 提供的 Cobra 命令风格的使用和帮助组件

Boa

Boa implements Cobra's help and usage functions to provided an interactive user experience by leveraging Bubbletea. User's no longer need to spend time running multiple help commands to see how nested sub commands work!

Install

Use go get to install the latest version of the library.

go get -u github.com/elewis787/boa@latest

Next, include Boa in your application:

import "github.com/elewis787/boa"

Usage

Using Boa is very simple. Below is an example on how to set the help/usage functions on a root command defined using Cobra.

go
	rootCmd := &cobra.Command{
		Version: "v0.0.1",
		Use:     "Example",
		Long:    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
		Short:   "example command",
		Example: "example [sub command]",
		RunE: func(cmd *cobra.Command, args []string) error {
		    return nil
		},
	}

	rootCmd.SetUsageFunc(boa.UsageFunc)
	rootCmd.SetHelpFunc(boa.HelpFunc)

The key lines are:

go
	rootCmd.SetUsageFunc(boa.UsageFunc)
	rootCmd.SetHelpFunc(boa.HelpFunc)

To futher customize the look and feel of boa, you can optional set additional styles or extend the defaults

go
	styles := boa.DefaultStyles()
	styles.Title.BorderForeground(lipgloss.AdaptiveColor{Light: `#E3BD2D`, Dark: `#E3BD2D`})
	styles.Border.BorderForeground(lipgloss.AdaptiveColor{Light: `#E3BD2D`, Dark: `#E3BD2D`})
	styles.SelectedItem.Foreground(lipgloss.AdaptiveColor{Light: `#353C3B`, Dark: `#353C3B`}).
		Background(lipgloss.AdaptiveColor{Light: `#E3BD2D`, Dark: `#E3BD2D`})

	b := boa.New(boa.WithStyles(styles))

	rootCmd.SetUsageFunc(b.UsageFunc)
	rootCmd.SetHelpFunc(b.HelpFunc)

Use the documentation to see a full list of styles as well as other available options that can be set.

Demo

Used by

  • rkl
  • m8
  • botway
  • gh-app-adm

Future work

  • Eval how styles are exported. Goal is to make it easy to customize the layout without needing to build a cmd parser for cobra
  • Add back button
  • Option to execute sub command
  • Adjust help based on cmd context availability
  • Other ideas ? - Open a feature request or submit a PR !

Issues· 7 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言