deprecation

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package deprecation provides helpers for marking CLI commands and flags as deprecated without hiding them from Cobra/pflag help output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandWarning

func CommandWarning(cmd *cobra.Command, dep Deprecation) string

CommandWarning formats the user-facing command deprecation warning.

func FlagWarning

func FlagWarning(dep Deprecation) string

FlagWarning formats the body pflag appends after "Flag --X has been deprecated, ". It uses the same Message/Replacement formatting as CommandWarning, with a generic fallback when both fields are empty so the pflag MarkDeprecated call never receives an empty body.

func MarkCommand

func MarkCommand(cmd *cobra.Command, dep Deprecation)

MarkCommand marks a Cobra command as deprecated while keeping it visible in help. A Deprecation with empty Message and Replacement is still applied; the runtime warning falls back to "command X is deprecated." in that case.

func MarkFlag

func MarkFlag(flags *pflag.FlagSet, name string, dep Deprecation) error

MarkFlag marks a flag as deprecated while keeping it visible in help. A Deprecation with empty Message and Replacement is still applied; the runtime warning falls back to a generic body in that case (pflag requires a non-empty deprecation body).

func WarnCommand

func WarnCommand(cmd *cobra.Command, dep Deprecation)

WarnCommand writes the deprecation warning for a command to stderr.

Types

type Deprecation

type Deprecation struct {
	Message     string
	Replacement string
}

Deprecation describes why a command or flag is deprecated and what users should use instead. Both fields are optional; when both are empty, helpers still mark the target and emit a generic deprecation warning.

Jump to

Keyboard shortcuts

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