flags

package
v0.80.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package flags provides reusable flag helpers for CLI commands.

This package should only contain common flags that can be used by multiple commands to ensure unified naming and consistent behavior across the CLI. Command-specific flags should be defined locally in the command file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Environment

func Environment(cmd *cobra.Command)

Environment adds the required --environment/-e flag to a command. Retrieve the value with cmd.Flags().GetString("environment").

Usage:

flags.Environment(cmd)
// later in RunE:
env, _ := cmd.Flags().GetString("environment")

func MustBool

func MustBool(b bool, _ error) bool

MustBool returns the bool value, ignoring the error. Safe to use with registered flags where GetBool cannot fail.

func MustString

func MustString(s string, _ error) string

MustString returns the string value, ignoring the error. Safe to use with registered flags where GetString cannot fail.

func Output

func Output(cmd *cobra.Command, defaultValue string)

Output adds the --out/-o flag for specifying output file path. Also supports deprecated --outputPath alias for backwards compatibility. Retrieve the value with cmd.Flags().GetString("out").

Usage:

flags.Output(cmd, "")
// later in RunE:
outPath, _ := cmd.Flags().GetString("out")

func Print

func Print(cmd *cobra.Command)

Print adds the --print flag for printing output to stdout (default: true). Retrieve the value with cmd.Flags().GetBool("print").

Usage:

flags.Print(cmd)
// later in RunE:
shouldPrint, _ := cmd.Flags().GetBool("print")

Types

This section is empty.

Jump to

Keyboard shortcuts

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