cobrautils

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 4 Imported by: 3

README

Cobra Utils

  • reflectを用いてcobra.Commandのプライベートなフィールドにアクセスします。
  • コマンドのテスト可用性と可読性を両立するサブコマンド構成を実現するための関数を提供します。
  • PersistentPreRunEを再帰的に実行するユーティリティを提供します。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindSubCmds

func BindSubCmds(root *cobra.Command)

func CallCmd

func CallCmd(me *cobra.Command, target cobra.Command, args ...string) error

指定されたサブコマンドを、現在のcmdと同じ環境で実行します

func CmdUtils

func CmdUtils(c *cobra.Command) *cmd

func GetHelpCommand

func GetHelpCommand(cmd *cobra.Command) *cobra.Command

func GetInternalAllSubCmds

func GetInternalAllSubCmds(cmd *cobra.Command) []*cobra.Command

func GetInternalSubCmdByName

func GetInternalSubCmdByName(cmd *cobra.Command, name string) *cobra.Command

func GetSubCmds

func GetSubCmds() []*cobra.Command

func RegisterSubCmd

func RegisterSubCmd(cmds ...*cobra.Command)

func WithParentPersistentPreRunE

func WithParentPersistentPreRunE(f func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error

Types

type Registory

type Registory []*cobra.Command

func (*Registory) BindSubCmds

func (r *Registory) BindSubCmds(root *cobra.Command)

サブコマンドをRootに追加する

func (*Registory) GetSubCmds

func (r *Registory) GetSubCmds() []*cobra.Command

サブコマンドの一覧を取得する

func (*Registory) RegisterSubCmd

func (r *Registory) RegisterSubCmd(cmds ...*cobra.Command)

サブコマンドを追加する

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL