flags

package
v5.73.1 Latest Latest
Warning

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

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

Documentation

Overview

Package flags provides CLI flag handling utilities including benchmark timing.

Index

Constants

View Source
const (
	// BenchmarkFlagName is the global/root persistent flag that enables benchmark output.
	BenchmarkFlagName = "benchmark"
	// ConfigFlagName is the global/root persistent flag that specifies an alternate config file path.
	ConfigFlagName = "config"
)

Variables

This section is empty.

Functions

func GetConfigPath added in v5.72.0

func GetConfigPath(cmd *cobra.Command) (string, error)

GetConfigPath returns the config file path from the --config persistent flag. Returns an empty string if the flag is not set or not found.

func IsBenchmarkEnabled added in v5.30.0

func IsBenchmarkEnabled(cmd *cobra.Command) (bool, error)

IsBenchmarkEnabled reports whether the current command invocation has benchmark enabled.

The flag is defined as a root persistent flag and inherited by subcommands.

func MaybeTimer

func MaybeTimer(cmd *cobra.Command, tmr timer.Timer) timer.Timer

MaybeTimer returns the provided timer when benchmark output is enabled.

When benchmark is disabled (or the flag is unavailable), it returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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