Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrMenuUnavailable is returned by a MenuPrompter when there is no interactive terminal to draw the menu on (piped stdin, CI, cron).
Functions ¶
func NewClientForCmd ¶
NewClientForCmd builds a git.Client wired to cmd's IO streams and pins the remote from cfg when configured.
func RunMenu ¶ added in v0.15.1
RunMenu is the RunE body of a command group invoked with no subcommand: it shows a menu of subs and runs the picked one.
The picked subcommand's RunE receives cmd — the parent, currently executing command — rather than itself. cobra v1.1.3 offers no SetContext, and the parent is the only command carrying a live Context and IO streams. Flag reads on the parent tolerate the missing flags (pflag reports unknown flags as unchanged; pushflow.ReadFlags checks Lookup first), so the subcommand runs on its interactive defaults, exactly as branch.runE already dispatches to its own subcommands.
Esc / ctrl+c on the menu exits quietly; a non-interactive stdin prints the group's help instead, so scripts keep the pre-menu behaviour.
Types ¶
type MenuPrompter ¶ added in v0.15.1
type MenuPrompter interface {
// Select shows title above one entry per sub and returns the picked
// sub's Name(). It reports ErrMenuUnavailable when no terminal is
// attached and huh.ErrUserAborted when the user presses Esc / ctrl+c.
Select(ctx context.Context, title string, subs []*cobra.Command) (string, error)
}
MenuPrompter presents a list of subcommands and returns the Name() of the one the user picked. The production implementation opens a huh form; tests substitute a scripted one.
func NewHuhMenuPrompter ¶ added in v0.15.1
func NewHuhMenuPrompter() MenuPrompter
NewHuhMenuPrompter returns the huh-backed MenuPrompter used by the CLI.