features

package
v0.37.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package features enables a way to encode enabled features in a flag.FlagSet.

Example
Output:

flag "protected" requires feature "test-feature" to be provided in --enable-features

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled(fs *flag.FlagSet, name Feature) bool

Enabled returns true if a feature is enabled. Enable will panic if fs has not been passed to Register or name is an unknown feature.

func GetAllEnabled added in v0.25.0

func GetAllEnabled(fs *flag.FlagSet) []string

GetAllEnabled returns the list of all enabled features

func Register

func Register(fs *flag.FlagSet, ff []Feature)

Register sets a flag in fs to track enabled features. The list of possible features is enumerated by ff. ff must contain a unique set of case-insensitive features. Register will panic if ff is invalid.

func Validate

func Validate(fs *flag.FlagSet, deps []Dependency) error

Validate returns an error if any flags from deps were used without the corresponding feature being enabled.

If deps references a flag that is not in fs, Validate will panic.

Types

type Dependency

type Dependency struct {
	// Flag must be a flag name from a FlagSet.
	Flag string
	// Feature which must be enabled for Flag to be provided at the command line.
	Feature Feature
}

Dependency marks a Flag as depending on a specific feature being enabled.

type Feature

type Feature string

Feature is an experimental feature. Features are case-insensitive.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳