flags

package
v0.80.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 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 ChainSelector added in v0.80.1

func ChainSelector(cmd *cobra.Command, required bool)

ChainSelector adds the --selector/-s flag for specifying chain selector. If required is true, the flag is marked as required. Retrieve the value with cmd.Flags().GetUint64("selector").

Usage:

flags.ChainSelector(cmd, false) // optional
flags.ChainSelector(cmd, true)  // required
// later in RunE:
selector, _ := cmd.Flags().GetUint64("selector")

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 MustUint64 added in v0.80.1

func MustUint64(u uint64, _ error) uint64

MustUint64 returns the uint64 value, ignoring the error. Safe to use with registered flags where GetUint64 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")

func Proposal added in v0.80.1

func Proposal(cmd *cobra.Command)

Proposal adds the required --proposal/-p flag for specifying proposal file path. Retrieve the value with cmd.Flags().GetString("proposal").

Usage:

flags.Proposal(cmd)
// later in RunE:
proposalPath, _ := cmd.Flags().GetString("proposal")

func ProposalKind added in v0.80.1

func ProposalKind(cmd *cobra.Command, defaultKind string)

ProposalKind adds the --proposalKind/-k flag for specifying proposal type. The defaultKind parameter should be a valid proposal kind string (e.g., "timelock"). Retrieve the value with cmd.Flags().GetString("proposalKind").

Usage:

flags.ProposalKind(cmd, "timelock")
// later in RunE:
kind, _ := cmd.Flags().GetString("proposalKind")

Types

This section is empty.

Jump to

Keyboard shortcuts

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