cmdutils

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CobraCommand

func CobraCommand(
	use, short, long, buildInfo string,
	wrapperFunc func(context.Context, func(context.Context, *config.Config) error, *config.Config) error,
	businesFunc func(context.Context, *config.Config) error,
) *cobra.Command
Example
businessFunc := func(ctx context.Context, cfg *config.Config) error {
	fmt.Println("Running business logic")
	return nil
}

wrapperFunc := func(ctx context.Context, fn func(context.Context, *config.Config) error, cfg *config.Config) error {
	fmt.Println("Wrapper function called")
	return fn(ctx, cfg)
}

cmd := CobraCommand(
	"example",
	"Example command",
	"This is an example of how to use CobraCommand",
	"v1.0.0",
	wrapperFunc,
	businessFunc,
)

fmt.Printf("Command use: %s\n", cmd.Use)
Output:

Command use: example

func RunAsJob

func RunAsJob(ctx context.Context, fn func(context.Context, *config.Config) error, cfg *config.Config) error

func RunAsService

func RunAsService(ctx context.Context, fn func(context.Context, *config.Config) error, cfg *config.Config) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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