Documentation
¶
Overview ¶
Package globals provides access to global CLI flags and state. These are set by the root command and can be read by subcommands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyFlags ¶ added in v0.16.1
ApplyFlags reads the global CLI flags (--dry-run, --json, --trace) off the invoked command's flag set and applies them to process-wide state.
Cobra runs only the closest PersistentPreRun(E) in the command chain, so a subcommand tree that defines its own hook shadows the root's. Every PersistentPreRun(E) in the CLI must therefore call ApplyFlags first; otherwise the root's persistent flags are silently dropped for that tree and a --dry-run invocation mutates real state. Reading the values off the command's own flag set (persistent flags are inherited and merged at parse time) makes this correct regardless of which hook cobra invokes.
A flag that is not defined on the command is skipped, so ApplyFlags is safe on command trees built without the root's persistent flags.
func GuardMutation ¶ added in v0.16.1
GuardMutation is the dry-run backstop at the lowest boundaries that mutate external state: GitHub API writes (releases, tags, branch protection, the contents API) and git pushes. Every command gates --dry-run explicitly and prints its preview before any of these boundaries is reached, so on a correct dry run this guard is never hit and on a real run it is a no-op.
If a mutation path misses its explicit gate, the guard refuses the operation with a loud error rather than silently mutating (the data-safety failure) or silently skipping (which would hide the missing gate). Callers place it immediately before executing the state-changing request or command, never on read paths.
Types ¶
This section is empty.