cli

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package cli wires CLI subcommands to the store and clipboard.

The router is intentionally tiny: cmd/pe/main.go calls Run(args) and returns its exit code. Everything else lives behind testable methods on App so we can inject a temp store path and a fake clipboard.

Index

Constants

This section is empty.

Variables

View Source
var Version = "(devel)"

Version is set by main at startup (which itself receives a value from goreleaser's -ldflags "-X main.version=..."). Tests and stand-alone imports of this package see the placeholder.

Functions

This section is empty.

Types

type App

type App struct {
	Path string             // snippet file path; "" → store.DefaultPath()
	Out  io.Writer          // stdout; nil → os.Stdout
	Err  io.Writer          // stderr; nil → os.Stderr
	Copy func(string) error // clipboard sink; nil → clip.Copy
	Now  func() time.Time   // clock; nil → time.Now
}

App holds CLI dependencies. Zero value uses real defaults; tests override Path / Out / Err / Copy / Now.

func (*App) Run

func (a *App) Run(args []string) int

Run executes argv (without the program name) and returns an exit code:

0 — success
1 — runtime error (not found, already exists, no clipboard, etc.)
2 — usage error (bad / missing arguments, unknown subcommand)

Jump to

Keyboard shortcuts

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