cli

package
v0.26.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 332

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cmd *cobra.Command) int

Run provides the common boilerplate code around executing a cobra command. For example, it ensures that logging is set up properly. Logging flags get added to the command line if not added already. Flags get normalized so that help texts show them with hyphens. Underscores are accepted as alternative for the command parameters.

Run tries to be smart about how to print errors that are returned by the command: before logging is known to be set up, it prints them as plain text to stderr. This covers command line flag parse errors and unknown commands. Afterwards it logs them. This covers runtime errors.

Commands like kubectl where logging is not normally part of the runtime output should use RunNoErrOutput instead and deal with the returned error themselves.

func RunNoErrOutput added in v0.23.2

func RunNoErrOutput(cmd *cobra.Command) error

RunNoErrOutput is a version of Run which returns the cobra command error instead of printing it.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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