Documentation
¶
Index ¶
- Variables
- func CheckForUpdates() error
- func GenerateTooltipFromStdSpec(c stdimg.CommandSpec) string
- func GenerateValidationRulesFromStdSpec(c stdimg.CommandSpec) map[string]ValidationRule
- func GetImageInfoImage(img image.Image) (string, error)
- func LoadImage(path string) (image.Image, string, error)
- func NormalizeArgsFromStd(store *StdMetaStore, cmdName string, args []string) ([]string, error)
- func PreviewImage(img image.Image) error
- func PreviewSupported() bool
- func PromptLine(prompt string) (string, error)
- func PromptLineOrFzf(prompt string) (string, error)
- func PromptLineWithFzf(prompt string) (string, error)
- func PromptLineWithFzfReader(reader *bufio.Reader, prompt string) (string, error)
- func RunCLI()
- func SaveImage(path string, img image.Image) error
- func SelectCommandWithFzfStd(commands []stdimg.CommandSpec) (string, error)
- func SelectFileWithFzf(startDir string) (string, error)
- type EXIF
- type GPSData
- type ParamType
- type StdMetaStore
- type ValidationRule
Constants ¶
This section is empty.
Variables ¶
var Version = "0.1.0"
Functions ¶
func CheckForUpdates ¶
func CheckForUpdates() error
func GenerateTooltipFromStdSpec ¶
func GenerateTooltipFromStdSpec(c stdimg.CommandSpec) string
GenerateTooltipFromStdSpec produces a tooltip string from a stdimg.CommandSpec.
func GenerateValidationRulesFromStdSpec ¶
func GenerateValidationRulesFromStdSpec(c stdimg.CommandSpec) map[string]ValidationRule
GenerateValidationRulesFromStdSpec creates ValidationRule entries from a stdimg.CommandSpec.
func GetImageInfoImage ¶
GetImageInfoImage returns a short info string for an image.Image
func LoadImage ¶
LoadImage loads a file from disk into an image.Image. Supports PNG/JPEG/GIF based on file extension and decoders.
func NormalizeArgsFromStd ¶
func NormalizeArgsFromStd(store *StdMetaStore, cmdName string, args []string) ([]string, error)
NormalizeArgsFromStd normalizes args using stdimg command metadata provided via StdMetaStore. It mirrors NormalizeArgs but operates on StdMetaStore and rules from stdimg.CommandSpec.
func PreviewImage ¶
PreviewImage encodes an image.Image to PNG and previews it in terminal (delegates to previewPNGBytes).
func PreviewSupported ¶
func PreviewSupported() bool
PreviewSupported returns true if the running environment likely supports a terminal inline preview. We consider chafa availability as a valid fallback even if no inline/sixel protocol is detected.
func PromptLine ¶
PromptLine displays a prompt and reads a full line of input from the user. The returned string is trimmed of surrounding whitespace (including the newline).
func PromptLineOrFzf ¶
PromptLineOrFzf reads a full line from stdin and treats a single-line "/" as a request to invoke fzf for file selection. Behavior:
- Print the prompt.
- Read a full line (including spaces).
- If the trimmed line equals "/", launch fzf via SelectFileWithFzf(".").
- If fzf returns a non-empty selection, return it.
- If fzf is unavailable or selection is cancelled, fall back to a typed prompt (re-using PromptLine to read a full line).
- Otherwise return the trimmed line as the input value.
This approach preserves support for paths containing spaces because we read the entire input line instead of a single token.
func PromptLineWithFzf ¶
PromptLineWithFzf kept for backward compatibility; it delegates to PromptLineOrFzf (which reads the whole line and treats "/" as fzf trigger).
func PromptLineWithFzfReader ¶
PromptLineWithFzfReader is a convenience variant that reads from the provided bufio.Reader. This is useful when the caller already has a reader instance and wants to avoid creating a new one (ensures no input is lost to a separate buffered reader).
func SaveImage ¶
SaveImage saves an image.Image to disk using format inferred from the filename extension. Supports .png, .jpg/.jpeg, .gif
func SelectCommandWithFzfStd ¶
func SelectCommandWithFzfStd(commands []stdimg.CommandSpec) (string, error)
SelectCommandWithFzfStd displays a list of stdimg commands in fzf and returns the selected command name.
func SelectFileWithFzf ¶
SelectFileWithFzf launches fzf with a list of common image files found under startDir. It returns the full path of the selected file or an error if selection failed.
This implementation reuses the terminal detection helpers in terminal_preview.go (isKitty, isInlineImageCapable, isSixelCapable, PreviewSupported) to choose a reasonable --preview command for fzf. The preview will attempt to use the most capable renderer available for the detected terminal.
Note: This implementation shells out to `find` piped into `fzf`. It requires both `find` and `fzf` to be available in PATH. startDir may be "." or any directory path.
Types ¶
type EXIF ¶
type EXIF struct {
Make string `json:"make,omitempty"`
Model string `json:"model,omitempty"`
Software string `json:"software,omitempty"`
Orientation int `json:"orientation,omitempty"`
DateTime string `json:"datetime,omitempty"`
DateTimeOriginal string `json:"datetime_original,omitempty"`
ExposureTime string `json:"exposure_time,omitempty"` // original "num/den"
Exposure float64 `json:"exposure,omitempty"` // seconds
ShutterSpeed string `json:"shutter_speed,omitempty"`
ApertureValue float64 `json:"aperture_value,omitempty"`
FNumber float64 `json:"f_number,omitempty"`
MeteringMode int `json:"metering_mode,omitempty"`
Flash int `json:"flash,omitempty"`
ISOSpeed int `json:"iso,omitempty"`
FocalLength float64 `json:"focal_length_mm,omitempty"`
LensModel string `json:"lens_model,omitempty"`
GPS *GPSData `json:"gps,omitempty"`
Raw map[uint32]string `json:"raw,omitempty"`
}
EXIF represents a parsed subset of EXIF metadata with typed fields.
func ExtractEXIFStruct ¶
ExtractEXIFStruct reads JPEG file at path and returns a typed EXIF struct.
func (EXIF) GPSLatLong ¶
GPSLatLong returns the GPS latitude and longitude if present. The boolean indicates presence.
type GPSData ¶
type GPSData struct {
Latitude float64 `json:"lat,omitempty"`
Longitude float64 `json:"lon,omitempty"`
LatRef string `json:"lat_ref,omitempty"`
LonRef string `json:"lon_ref,omitempty"`
Altitude float64 `json:"altitude,omitempty"`
AltitudeRef int `json:"alt_ref,omitempty"`
GPSTimeStamp string `json:"gps_time_stamp,omitempty"`
GPSDateStamp string `json:"gps_date_stamp,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
Raw map[uint16]string `json:"raw,omitempty"`
}
GPSData holds parsed GPS coordinates and raw GPS tag values.
type ParamType ¶
type ParamType string
ParamType is a small enum for parameter types used in metadata.
type StdMetaStore ¶
type StdMetaStore struct {
Commands []stdimg.CommandSpec
// contains filtered or unexported fields
}
StdMetaStore is a MetaStore-like wrapper for stdimg.CommandSpec.
func NewMetaStoreFromStdimg ¶
func NewMetaStoreFromStdimg(cmds []stdimg.CommandSpec) *StdMetaStore
NewMetaStoreFromStdimg creates a StdMetaStore from stdimg.CommandSpec list.
func (*StdMetaStore) GetCommandHelp ¶
func (m *StdMetaStore) GetCommandHelp(name string) (string, map[string]ValidationRule, error)
GetCommandHelp returns both tooltip and validation rules for a stdimg command.
func (*StdMetaStore) GetTooltip ¶
func (m *StdMetaStore) GetTooltip(name string) (string, error)
GetTooltip returns tooltip string for a stdimg command.
func (*StdMetaStore) GetValidationRules ¶
func (m *StdMetaStore) GetValidationRules(name string) (map[string]ValidationRule, error)
GetValidationRules returns validation rules for a stdimg command.
type ValidationRule ¶
type ValidationRule struct {
Type ParamType `json:"type"`
Required bool `json:"required"`
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
Unit string `json:"unit,omitempty"`
Pattern string `json:"pattern,omitempty"` // optional regex-like pattern or note
EnumOptions []string `json:"enumOptions,omitempty"` // valid when Type == ParamTypeEnum
Example string `json:"example,omitempty"`
Hint string `json:"hint,omitempty"`
}
ValidationRule is a machine-friendly representation of the constraints that a UI or client can use to validate input before invoking a command.