clipboard

package
v0.2.0-rc.3 Latest Latest
Warning

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

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

Documentation

Overview

Package clipboard provides cross-platform clipboard copy utilities for the StackEye CLI. It supports macOS (pbcopy), Linux (xclip or xsel), and Windows (clip.exe), with a graceful fallback that prints the text when the clipboard is not available.

Usage:

if err := clipboard.Copy("se_abc123..."); err != nil {
    // handle error
}

// Or with automatic fallback to printing the text:
clipboard.CopyOrPrint("se_abc123...")

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyText = fmt.Errorf("clipboard: text must not be empty")

ErrEmptyText is returned when an empty string is passed to Copy.

Functions

func Copy

func Copy(text string) error

Copy copies the given text to the system clipboard. It returns an error if the text is empty, the platform is unsupported, or the clipboard command fails.

func CopyOrPrint

func CopyOrPrint(text string) error

CopyOrPrint attempts to copy text to the clipboard. If the clipboard is unavailable or the copy fails, it prints the text to stderr so the user can copy it manually. This never returns an error for clipboard failures — only for invalid input.

func SetCopier

func SetCopier(fn func(string) error)

SetCopier replaces the function used to copy text to the clipboard. Pass nil to restore the default platform-specific behaviour. Intended for testing only.

Types

This section is empty.

Jump to

Keyboard shortcuts

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