app

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

Variables

View Source
var EmptyCompResult = &CompResult{
	Flag: cobra.ShellCompDirectiveNoFileComp,
}

Functions

func Comp

func Comp(actions ...CompAction) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

func Delete added in v0.6.0

func Delete(name, path string) error

func Edit added in v0.6.0

func Edit(path, defaultContent, name string, validate func(s string) error) error

func Register

func Register[Flags, Data any](app *Command[Flags, Data]) *cobra.Command

func Root

func Root(cmd *cobra.Command)

Types

type Command

type Command[Flags, Data any] struct {
	Use    string
	Desc   string
	Action string

	Prepare PrepareFunction[Flags]

	PrepareNoFlag func(cmd *cobra.Command)

	Init InitFunction[Flags, Data]

	Run RunFunction[Flags, Data]

	RunNoContext func() error
}

type CompAction

type CompAction func(args []string) (*CompResult, error)

func CompGitLocalBranch

func CompGitLocalBranch(current bool) CompAction

type CompResult

type CompResult struct {
	Items []string
	Flag  cobra.ShellCompDirective
}

func CompBuilder added in v0.2.0

func CompBuilder(_ []string) (*CompResult, error)

func CompGitRemote

func CompGitRemote(_ []string) (*CompResult, error)

func CompGitRemoteBranch

func CompGitRemoteBranch(_ []string) (*CompResult, error)

func CompGitTag

func CompGitTag(_ []string) (*CompResult, error)

func CompGroup

func CompGroup(args []string) (*CompResult, error)

func CompJob added in v0.2.0

func CompJob(_ []string) (*CompResult, error)

func CompRemote

func CompRemote(_ []string) (*CompResult, error)

func CompRepo

func CompRepo(args []string) (*CompResult, error)

func CompTemplate added in v0.5.0

func CompTemplate(_ []string) (*CompResult, error)

func CompWorkflow added in v0.2.0

func CompWorkflow(_ []string) (*CompResult, error)

type Context

type Context[Flags, Data any] struct {
	Flags *Flags
	Data  *Data
	// contains filtered or unexported fields
}

func (*Context[Flags, Data]) Arg

func (ctx *Context[Flags, Data]) Arg(idx int) string

func (*Context[Flags, Data]) ArgDefault

func (ctx *Context[Flags, Data]) ArgDefault(idx int, def string) string

func (*Context[Flags, Data]) ArgLen

func (ctx *Context[Flags, Data]) ArgLen() int

func (*Context[Flags, Data]) OnClose

func (ctx *Context[Flags, Data]) OnClose(f func() error)

type Empty

type Empty struct{}

type InitFunction

type InitFunction[Flags, Data any] func(ctx *Context[Flags, Data]) error

type PrepareFunction

type PrepareFunction[Flags any] func(cmd *cobra.Command, flags *Flags)

type RunFunction

type RunFunction[Flags, Data any] func(ctx *Context[Flags, Data]) error

Jump to

Keyboard shortcuts

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