cmd

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package cmd implements the memelink CLI commands and Kong parser setup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(args []string) (err error)

Execute parses CLI args, sets up context, and runs the matched command.

func ExitCode

func ExitCode(err error) int

ExitCode extracts the exit code from an error. Returns 0 for nil, the embedded code for ExitError, 1 otherwise.

func VersionString

func VersionString() string

VersionString returns a human-readable version string.

Types

type CLI

type CLI struct {
	RootFlags `embed:""`

	Version    kong.VersionFlag `help:"Print version and exit"`
	VersionCmd VersionCmd       `cmd:"" name:"version" help:"Print version info"`
	Generate   GenerateCmd      `cmd:"" name:"generate" aliases:"gen,g" default:"withargs" help:"Generate a meme"`
	Templates  TemplatesCmd     `cmd:"" name:"templates" aliases:"ls" help:"List or view templates"`
	Fonts      FontsCmd         `cmd:"" name:"fonts" help:"List or view fonts"`
	Config     ConfigCmd        `cmd:"" name:"config" help:"Manage configuration"`
}

CLI is the top-level Kong command struct.

type ConfigCmd

type ConfigCmd struct {
	Path  ConfigPathCmd  `cmd:"" help:"Show config file path"`
	List  ConfigListCmd  `cmd:"" help:"List all config values"`
	Get   ConfigGetCmd   `cmd:"" help:"Get a config value"`
	Set   ConfigSetCmd   `cmd:"" help:"Set a config value"`
	Unset ConfigUnsetCmd `cmd:"" help:"Unset a config value"`
}

ConfigCmd groups configuration subcommands.

type ConfigGetCmd

type ConfigGetCmd struct {
	Key string `arg:"" help:"Config key to get"`
}

ConfigGetCmd gets a single config value.

func (*ConfigGetCmd) Run

func (c *ConfigGetCmd) Run(ctx context.Context) error

Run prints the value for the given key.

type ConfigListCmd

type ConfigListCmd struct{}

ConfigListCmd lists all config values.

func (*ConfigListCmd) Run

func (c *ConfigListCmd) Run(ctx context.Context) error

Run lists all config keys with their values.

type ConfigPathCmd

type ConfigPathCmd struct{}

ConfigPathCmd prints the config file path.

func (*ConfigPathCmd) Run

func (c *ConfigPathCmd) Run(_ context.Context) error

Run prints the config file path.

type ConfigSetCmd

type ConfigSetCmd struct {
	Key   string `arg:"" help:"Config key"`
	Value string `arg:"" help:"Config value"`
}

ConfigSetCmd sets a config value.

func (*ConfigSetCmd) Run

func (c *ConfigSetCmd) Run(_ context.Context) error

Run sets a config key to a value, persisting to disk.

type ConfigUnsetCmd

type ConfigUnsetCmd struct {
	Key string `arg:"" help:"Config key to unset"`
}

ConfigUnsetCmd removes a config value.

func (*ConfigUnsetCmd) Run

func (c *ConfigUnsetCmd) Run(_ context.Context) error

Run unsets a config key, persisting to disk.

type ExitError

type ExitError struct {
	Code int
	Err  error
}

ExitError wraps an error with a process exit code.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type FontsCmd

type FontsCmd struct {
	ID string `arg:"" optional:"" help:"Font ID for detail view"`
}

FontsCmd lists or views fonts.

func (*FontsCmd) Run

func (c *FontsCmd) Run(ctx context.Context) error

Run executes the fonts command, dispatching to detail or list view.

type GenerateCmd

type GenerateCmd struct {
	// Positional: first is template ID or auto-generate text; rest are text lines.
	Template string   `arg:"" optional:"" help:"Template ID (omit for auto-generate, 'custom' for custom background)"`
	Text     []string `arg:"" optional:"" help:"Text lines for the meme"`

	// Customization flags -- defaults empty; cascade fills from config/hardcoded.
	Format     string   `help:"Image format (jpg,png,gif,webp)" short:"f"`
	Font       string   `help:"Font ID or alias" name:"font"`
	TextColor  []string `help:"Text color per line (repeatable)" name:"text-color" sep:"none"`
	Layout     string   `help:"Text layout (default,top)" name:"layout"`
	Style      []string `help:"Style name or overlay URL (repeatable)" name:"style" sep:"none"`
	Width      int      `help:"Image width in pixels" name:"width"`
	Height     int      `help:"Image height in pixels" name:"height"`
	Center     string   `help:"Overlay center position (x,y)" name:"center"`
	Scale      string   `help:"Overlay scale ratio" name:"scale"`
	Safe       bool     `help:"Filter NSFW content" name:"safe"`
	Background string   `help:"Custom background image URL (use with 'custom' template)" name:"background"`

	// Output action flags.
	Copy       bool   `help:"Copy URL to clipboard" name:"copy" short:"c"`
	Open       bool   `help:"Open URL in browser" name:"open" short:"o"`
	Output     string `help:"Download image to file path" name:"output"`
	AutoOutput bool   `help:"Download image to CWD with auto-generated name" short:"O"`

	// Preview flag.
	Preview *bool `help:"Show inline image preview" name:"preview" negatable:""`
}

GenerateCmd generates a meme. It is the default command when invoked with positional args (default:"withargs" in CLI struct).

func (*GenerateCmd) Run

func (c *GenerateCmd) Run(ctx context.Context, root *RootFlags) error

Run executes the generate command, dispatching to one of three modes: auto-generate, template-based, or custom-background.

type RootFlags

type RootFlags struct {
	Color   string `help:"Color output: auto|always|never" default:"auto" enum:"auto,always,never"`
	JSON    bool   `help:"JSON output" default:"false"`
	Verbose bool   `help:"Verbose logging" default:"false"`
	NoInput bool   `help:"Never prompt; fail instead" name:"no-input" default:"false"`
	Force   bool   `help:"Skip confirmations" default:"false"`
}

RootFlags are global flags available to all commands.

type TemplatesCmd

type TemplatesCmd struct {
	ID       string `arg:"" optional:"" help:"Template ID for detail view"`
	Filter   string `help:"Filter templates by name/keyword" name:"filter"`
	Animated bool   `help:"Show only animated-capable templates" name:"animated"`
	Refresh  bool   `help:"Force cache refresh" name:"refresh"`
}

TemplatesCmd lists or views meme templates.

func (*TemplatesCmd) Run

func (c *TemplatesCmd) Run(ctx context.Context, root *RootFlags) error

Run executes the templates command, dispatching to detail, interactive, or list view.

type VersionCmd

type VersionCmd struct{}

VersionCmd prints version information.

func (*VersionCmd) Run

func (c *VersionCmd) Run(ctx context.Context) error

Run executes the version command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL