Documentation
¶
Index ¶
- func BuildImageInput(arg string) (string, error)
- func BuildMediaInput(arg string) (string, error)
- 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, format output.Format, err error)
- func PrintErrorMsg(logger *log.Logger, format output.Format, message string, err error)
- func PrintErrorMsgTo(logger *log.Logger, w io.Writer, format output.Format, message string, ...)
- func PrintErrorTo(logger *log.Logger, w io.Writer, format output.Format, err error)
- func SplitModelArgs(args []string) (model string, kvArgs []string)
- type Spinner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildImageInput ¶ added in v1.1.0
BuildImageInput converts a CLI argument into an image value for the imageUpload task, which accepts images only. Remote URLs and data URIs are returned unchanged; local file paths are read, validated to be a supported image, and encoded as a data URI. Use BuildMediaInput for mediaStorage, which accepts any media type.
func BuildMediaInput ¶ added in v1.1.0
BuildMediaInput converts a CLI argument into a media value for the mediaStorage task, which accepts any media type (image, video, audio, 3D, and more). Remote URLs and data URIs are returned unchanged; local file paths are read and encoded as a data URI with a best-effort content type, without restricting the type.
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 where the model AIR may appear:
0 → run <model> [key=value ...] 1 → preset save <name> <model> [key=value ...]
The model is taken from args when present; when the args at modelArgIdx are already key=value pairs (or absent), the command's --preset flag is consulted and the preset supplies the model. With no model from either source, no completions are offered. Once the model is known, its JSON Schema is fetched and dot-notation leaf completions are returned for parameters not already typed on the command line. Keys the preset sets are still suggested — they can be overridden — with their preset value shown in the description. 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 (whose default reflects the config's defaults.transport) 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 with formatting that matches the CLI output format.
Special cases:
- transport.ErrNoAPIKey → friendly "no key" message with auth hint
- *transport.RunwareError CodeAuth → "Authentication failed" with auth hint
- *transport.RunwareError other → full API error fields (JSON/YAML) or structured key-value fields (table)
For all other errors, err.Error() is used as the message.
func PrintErrorMsg ¶ added in v0.7.0
PrintErrorMsg logs a custom message, appending structured API error fields when err is a *transport.RunwareError. Use for warning-style output that does not exit the process.
func PrintErrorMsgTo ¶ added in v0.11.1
func PrintErrorMsgTo(logger *log.Logger, w io.Writer, format output.Format, message string, err error)
PrintErrorMsgTo logs a custom message and writes structured output to w.
func PrintErrorTo ¶ added in v0.11.1
PrintErrorTo logs err with formatting that matches the CLI output format, writing structured output to w.
func SplitModelArgs ¶ added in v0.10.0
SplitModelArgs splits positional args into the model AIR and key=value pairs. Model AIRs never contain "=", so a first argument containing "=" means the model was omitted (it then comes from a preset).
Types ¶
type Spinner ¶ added in v0.10.0
type Spinner struct {
// contains filtered or unexported fields
}
Spinner wraps the briandowns/spinner with a simplified API for consistent processing-state feedback across all CLI commands.
func NewSpinner ¶ added in v0.10.0
NewSpinner creates a spinner that writes to stderr with the given initial message.
func (*Spinner) Restart ¶ added in v0.11.0
func (sp *Spinner) Restart()
Restart stops and restarts the spinner. Use this instead of Stop+Start to reliably resume the animation.
func (*Spinner) SetMessage ¶ added in v0.10.0
SetMessage updates the spinner suffix text while it is running.