Documentation
¶
Overview ¶
Package cmdutil provides the Factory injected into every command: lazily-resolved config, token store, and API client, plus the values of the persistent --json/--server/--app flags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶ added in v0.2.0
Confirm gates a significant but non-deletion action behind the same rule as ConfirmDeletion: --yes skips the prompt, an interactive terminal is asked y/N, and a non-interactive caller without --yes is refused with a Usage error so the action is always explicit. `prompt` is the full question, without the trailing " (y/N)".
func ConfirmDeletion ¶
ConfirmDeletion gates destructive commands. --yes skips the prompt; otherwise an interactive terminal asks y/N, and a non-interactive caller (scripts, agents) is refused with a Usage error so deletions are always explicit.
func ResolveNodeURN ¶
ResolveNodeURN turns a fully-qualified node URN into a node ID via Query.resolveUrn. Bare locs are rejected client-side with a usage error: node references always name the memory (same-loc collisions across memories made anything less ambiguous). A URN that resolves to a different entity kind is a usage error too.
Types ¶
type Factory ¶
type Factory struct {
IOStreams *output.IOStreams
HTTPClient *http.Client
// Persistent flag values, bound by the root command.
JSON bool
ServerFlag string
AppFlag string
// Overridable for tests.
ConfigFn func() (*config.Config, error)
TokenStoreFn func() store.Store
// contains filtered or unexported fields
}
func NewFactory ¶
func NewFactory() *Factory
func (*Factory) App ¶
App resolves the App URN context: --app flag, then config default. Empty means no App context, which the server treats as fine.
func (*Factory) GraphQLClient ¶
GraphQLClient returns an authenticated genqlient client, failing with the AuthRequired exit code when no credentials are present.
func (*Factory) Server ¶
Server resolves the server base URL: --server flag, then HADRON_SERVER env, then config, then the hosted default.
func (*Factory) Token ¶
func (f *Factory) Token() (string, auth.TokenSource, error)
Token returns the active token and its source for the resolved server ("" source when unauthenticated). HADRON_TOKEN is checked before the token store so CI never triggers a keyring probe.