deprecation

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package deprecation provides the CLI deprecation warning system.

Usage:

reg, err := deprecation.LoadRegistry("internal/deprecation/registry.yaml")
if err != nil {
    // warn in debug log, do not crash
}
if item, ok := reg.Lookup("nself old-cmd"); ok {
    reg.Warn(os.Stderr, item)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Warn

func Warn(w io.Writer, name, since, replacement, docsURL string)

Warn is a package-level convenience that creates a one-shot warning without needing a Registry. Used for inline deprecations.

Types

type Item

type Item struct {
	Name        string   `yaml:"name"`
	Type        ItemType `yaml:"type"`
	Since       string   `yaml:"since"`
	Replacement string   `yaml:"replacement"`
	DocsURL     string   `yaml:"docs_url"`
	Phase       int      `yaml:"phase"`
}

Item represents a single deprecated CLI element.

type ItemType

type ItemType string

ItemType classifies the deprecated surface.

const (
	TypeCommand ItemType = "command"
	TypeFlag    ItemType = "flag"
	TypeEnv     ItemType = "env"
)

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds the loaded deprecation entries.

func LoadRegistry

func LoadRegistry(path string) (*Registry, error)

LoadRegistry reads the YAML registry file and returns a Registry. If the file does not exist or fails to parse, it returns an empty Registry and a non-nil error (caller should log in debug mode, not crash).

func (*Registry) IsDeprecated

func (r *Registry) IsDeprecated(name string) bool

IsDeprecated returns true if the given name is in the registry.

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (Item, bool)

Lookup returns the Item for the given name and true if found.

func (*Registry) Warn

func (r *Registry) Warn(w io.Writer, item Item)

Warn writes a deprecation warning for item to w (should be os.Stderr). Format: [DEPRECATED] 'nself <item>' (since v<X.Y.Z>) → use 'nself <replacement>'. Docs: <url>

Jump to

Keyboard shortcuts

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