Documentation
¶
Overview ¶
Package deprecation provides helpers for marking CLI commands and flags as deprecated without hiding them from Cobra/pflag help output.
Index ¶
- func CommandWarning(cmd *cobra.Command, dep Deprecation) string
- func FlagWarning(dep Deprecation) string
- func MarkCommand(cmd *cobra.Command, dep Deprecation)
- func MarkFlag(flags *pflag.FlagSet, name string, dep Deprecation) error
- func WarnCommand(cmd *cobra.Command, dep Deprecation)
- type Deprecation
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 ¶
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.