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 ¶
- func ChainSelector(cmd *cobra.Command, required bool)
- func Environment(cmd *cobra.Command)
- func MustBool(b bool, _ error) bool
- func MustString(s string, _ error) string
- func MustUint64(u uint64, _ error) uint64
- func Output(cmd *cobra.Command, defaultValue string)
- func Print(cmd *cobra.Command)
- func Proposal(cmd *cobra.Command)
- func ProposalKind(cmd *cobra.Command, defaultKind string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChainSelector ¶ added in v0.80.1
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 ¶
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 ¶
MustBool returns the bool value, ignoring the error. Safe to use with registered flags where GetBool cannot fail.
func MustString ¶
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
MustUint64 returns the uint64 value, ignoring the error. Safe to use with registered flags where GetUint64 cannot fail.
func Output ¶
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 ¶
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
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
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.