Documentation
¶
Overview ¶
Package cmdctx threads the resolved auto-approve policy from the root command's PersistentPreRunE down to every Cobra subcommand's Run via a typed context key. Pure plumbing; the policy itself lives in internal/approval.
Why a separate package: keeping the context-key type unexported here and exposing only With/From accessors prevents accidental cross-package shadow keys, and lets the approval package stay focused on policy resolution without leaking Cobra-shaped helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Approval ¶
Approval is the Cobra-shaped sugar: read the Resolved off the command's own context. Equivalent to ApprovalFromContext(cmd.Context()) but reads more naturally at the call site of a Run function.
func ApprovalFromContext ¶
ApprovalFromContext returns the Resolved stashed by WithApproval. A context without one yields the zero value — Auto=false, ConfirmFloor at the zero tier — which is the safe cautious default (every approval.Confirm call falls through to the interactive prompt).
func WithApproval ¶
WithApproval returns a child context carrying r. main.go's PersistentPreRunE calls this once at startup and SetContext's the result onto the executing command so every descendant Run sees the same Resolved.
Types ¶
This section is empty.