cli

package
v0.0.0-...-f0ce2a6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 16

Documentation

Overview

Making CLI commands have some quality without too much boilerplate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLogLevelControls

func AddLogLevelControls(flags *pflag.FlagSet)

adds CLI flags that control the logging level

func Execute

func Execute(app *cobra.Command)

wraps the `Execute()` call of the command to inject boilerplate details like `Use`, `Version` and handling of error to `Command.Execute()` (such as flag validation, missing command etc.)

func Runner

func Runner(run func(ctx context.Context, args []string, logger *log.Logger) error) func(*cobra.Command, []string)

func RunnerNoArgs

func RunnerNoArgs(run func(ctx context.Context, logger *log.Logger) error) func(*cobra.Command, []string)

func WrapRun

func WrapRun(run func(ctx context.Context, args []string) error) func(*cobra.Command, []string)

fixes problems of cobra commands' bare run callbacks with regards to application quality: 1. logging not configured 2. no interrupt handling 3. no error handling

Types

This section is empty.

Jump to

Keyboard shortcuts

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