clictx

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package clictx carries the global per-invocation state (flags, cancellable context) attached to every cobra command, so subcommand packages can read it without importing the root cli package and creating an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attach

func Attach(cmd *cobra.Command, ctx context.Context, flags *Flags)

Attach installs flags on cmd's context. Call from the root command's PersistentPreRunE so children inherit it.

Types

type Flags

type Flags struct {
	AuthOverride   string
	WebAppOverride string
	OrgOverride    string
	Output         string
	NoPager        bool
}

Flags are the values of the persistent flags declared on the root command.

func Get

func Get(cmd *cobra.Command) *Flags

Get returns the Flags attached by Attach. Returns a zero Flags struct if nothing is attached, so callers don't need to nil-check.

func (*Flags) HasOrgFlag

func (g *Flags) HasOrgFlag() bool

HasOrgFlag reports whether --org was explicitly set on the command line. Used by callers that need to know the difference between "user said --org=foo" and "fell back to active org" — for example, langsync's project-config override should only kick in when --org is NOT set.

func (*Flags) ResolveAuth

func (g *Flags) ResolveAuth(cfg *config.Config) string

ResolveAuth returns the auth-service base URL: --auth-url > config.auth.

func (*Flags) ResolveOrg

func (g *Flags) ResolveOrg(cfg *config.Config) (id, slug string)

ResolveOrg returns the org id+slug for this invocation. The --org flag (slug or id) wins over the persisted active org. When --org is set we can't tell whether it's a slug or id without a round trip, so both are returned identical and the caller resolves as needed.

func (*Flags) ResolveWebApp

func (g *Flags) ResolveWebApp(cfg *config.Config) string

ResolveWebApp returns the web-app base URL: --web-app > config.web_app.

Jump to

Keyboard shortcuts

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