Documentation
¶
Overview ¶
Package cli holds common-flag glue: the Options struct cobra binds the truly provider-agnostic flags onto, and provider-agnostic validation. Provider-specific flags (model, size, aspect ratio, quality, …) live inside each provider's BindFlags/ReadFlags.
Index ¶
- Constants
- Variables
- func IsBatchPath(path string) bool
- func IsCommonFlag(name string) bool
- func NormalizeSeparator(raw string) (string, error)
- func ResolvePromptParts(parts []string, separator, baseDir string) (string, error)
- func ResolvePromptText(value, baseDir string) (string, error)
- type Options
Constants ¶
const SeparatorFlagDefault = `\n\n`
SeparatorFlagDefault is a blank line in escaped form, so --help prints (default "\n\n") on one line.
Variables ¶
var CommonFlagNames = map[string]bool{ "prompt": true, "separator": true, "output": true, "filename": true, "count": true, "input": true, "replace": true, "provider": true, "max-parallel": true, "embed-metadata": true, "help": true, "version": true, }
CommonFlagNames lists the truly provider-agnostic flag names — the long forms of the flags bound on the root command in commands/root.go. Single source of truth: both the single-shot validation gate and the batch path read from this map. Any flag not listed here must be claimed by at least one provider's Bundle.SupportedFlags.
Functions ¶
func IsBatchPath ¶ added in v1.2.1
IsBatchPath returns true if path's extension marks it as a batch file. Delegates to paths.IsBatchFile so cli and batch always agree.
func IsCommonFlag ¶ added in v1.2.1
IsCommonFlag reports whether name is a common (provider-agnostic) flag.
func NormalizeSeparator ¶ added in v1.3.7
NormalizeSeparator rejects an empty separator, expands escapes, and puts an unpadded newline-free token on its own line ("---" → "\n---\n").
func ResolvePromptParts ¶ added in v1.3.7
ResolvePromptParts resolves each part through ResolvePromptText and joins them, dropping empty values.
func ResolvePromptText ¶ added in v1.2.4
ResolvePromptText resolves a prompt value to literal text: a file path (relative to baseDir, "" = CWD) becomes its trimmed contents, else verbatim.
Types ¶
type Options ¶
type Options struct {
// Prompts holds the raw -p values in order: text, file paths, or (alone) a batch file.
Prompts []string
// Separator is the raw --separator value, normalised by NormalizeSeparator.
Separator string
// Prompt is what Validate resolves Prompts to: parts read and joined, or the batch path.
Prompt string
Output string
OutputFilename string
NumImages int
RefInputs []string
PreserveFilename bool
// MaxParallel caps concurrent provider HTTP requests — covers both
// single-shot per-count fan-out and batch per-entry fan-out via a
// shared semaphore threaded into api.Params. 0 (default) means
// unlimited, the pre-existing behaviour.
MaxParallel int
// EmbedMetadata embeds prompt/model/provider into PNG output (--embed-metadata).
EmbedMetadata bool
// IsBatch is set by Validate when the single -p resolves to a batch file
// (.yaml/.yml/.json). Callers branch on this to call internal/batch
// instead of building a single-shot Request.
IsBatch bool
}
Options holds the truly common CLI flags — same meaning for every provider. Everything provider-specific lives inside each provider's bundle and ends up in Request.Options.
func (*Options) Validate ¶
Validate runs provider-agnostic checks:
- at least one non-empty -p (reading from a file if the value points at a path)
- tilde expansion in -o, -i
- -n is in range
- -i paths exist and contain supported images
- -f and -r are mutually exclusive (cobra also enforces)
- -r requires exactly one -i pointing at a single file.