Documentation
¶
Index ¶
- func CollectCompletions(prefix string, node schema.Node, provided map[string]struct{}, ...) []cobra.Completion
- func FormatFor(cmd *cobra.Command) output.Format
- func MakeSchemaArgCompleter(modelArgIdx int) ...
- func NewTransport(cmd *cobra.Command, logger *slog.Logger) (transport.Transport, error)
- func PrintError(logger *log.Logger, err error)
- func PrintErrorMsg(logger *log.Logger, message string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectCompletions ¶ added in v0.9.0
func CollectCompletions( prefix string, node schema.Node, provided map[string]struct{}, toCompletePrefix string, nextArrayIdx func(string) int, ) []cobra.Completion
CollectCompletions recursively walks a schema node and emits a dot-notation "key=" completion for every leaf property. prefix is the dot-path built so far (empty at the top level). Object properties are recursed into; array fields use nextArrayIdx to determine the next index to suggest.
func FormatFor ¶
FormatFor returns the output format for a command from the --format flag. The flag's default is set to the user's configured default at startup (see NewRootCmd), so no separate config fallback is required here.
func MakeSchemaArgCompleter ¶ added in v0.9.0
func MakeSchemaArgCompleter(modelArgIdx int) func(*cobra.Command, []string, string) ([]cobra.Completion, cobra.ShellCompDirective)
MakeSchemaArgCompleter returns a ValidArgsFunction that provides schema-driven shell completion for key=value positional arguments. modelArgIdx is the index in args that holds the model AIR:
0 → run <model> [key=value ...] 1 → preset save <name> <model> [key=value ...]
When the model has not yet been typed (len(args) <= modelArgIdx), no completions are offered. Once the model is present, the model's JSON Schema is fetched and dot-notation leaf completions are returned for parameters not already provided. Completion is best-effort: failures are silently ignored.
func NewTransport ¶ added in v0.7.0
NewTransport dials a transport using the --transport flag on the root command and the API key from config. Callers are responsible for calling Close on the returned transport.
func PrintError ¶ added in v0.7.0
PrintError logs err to logger with appropriate formatting.
Special cases:
- transport.ErrNoAPIKey → friendly "no key" message with auth hint
- *transport.RunwareError CodeAuth → "Authentication failed" with auth hint
- *transport.RunwareError other → re.Message, with docs URL as a "docs" field
For all other errors, err.Error() is used as the message.
func PrintErrorMsg ¶ added in v0.7.0
PrintErrorMsg logs a custom message to logger, appending the documentation URL from err as a "docs" field when err is a *transport.RunwareError with one. Use this when a command needs to surface a context-specific message for an error but continue executing (warning-style) rather than exit.
Types ¶
This section is empty.