sys

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package sys provides system-level utilities for command execution, environment interaction, and clipboard operations.

Index

Constants

View Source
const (
	// ExitSuccess indicates normal termination.
	ExitSuccess = 0

	// ExitInterrupted is the conventional exit code for Ctrl+C (SIGINT).
	ExitInterrupted = 130

	// ExitFailure indicates a general failure or unhandled error.
	ExitFailure = 1
)

Exit codes used by the application.

Variables

View Source
var (
	ErrCopyToClipboard   = errors.New("copy to clipboard")
	ErrNotImplementedYet = errors.New("not implemented yet")
	ErrActionAborted     = errors.New("action aborted")
	ErrExitFailure       = errors.New("exit failure")
	ErrSysCmdNotFound    = errors.New("command not found")
)

Functions

func BinExists

func BinExists(s string) bool

BinExists checks if the binary exists in $PATH.

func BinPath

func BinPath(s string) string

BinPath returns the path of the binary.

func CopyClipboard

func CopyClipboard(s string) error

CopyClipboard copies a string to the clipboard.

func Env

func Env(s, def string) string

Env retrieves an environment variable.

If the environment variable is not set, returns the default value.

func ErrAndExit

func ErrAndExit(err error)

ErrAndExit logs the error and exits the program.

func ExecCmdWithWriter added in v0.1.15

func ExecCmdWithWriter(ctx context.Context, w io.Writer, s ...string) error

ExecCmdWithWriter runs a command with the given arguments and writes the output to the writer.

func ExecuteCmd

func ExecuteCmd(ctx context.Context, arg ...string) error

ExecuteCmd runs a command with the given arguments and returns an error if the command fails.

func OSArgs

func OSArgs() []string

OSArgs returns the correct arguments for the OS.

func OpenInBrowser

func OpenInBrowser(s string) error

OpenInBrowser opens a URL in the default browser.

func ReadClipboard

func ReadClipboard() string

ReadClipboard reads the contents of the clipboard.

func RegisterCleanup added in v0.1.30

func RegisterCleanup(fn func())

RegisterCleanup registers a function to be called during program cleanup.

func RunCmd

func RunCmd(ctx context.Context, s string, arg ...string) error

RunCmd returns an *exec.Cmd with the given arguments.

func Which added in v0.1.15

func Which(cmd string) (string, error)

Which checks if the command exists in $PATH.

func WithSignalContext added in v0.1.30

func WithSignalContext(parent context.Context) (context.Context, context.CancelFunc)

WithSignalContext returns a context that is canceled when an interrupt or termination signal is received.

Types

This section is empty.

Directories

Path Synopsis
Package browser defines an interface for interacting with web browsers to import bookmarks.
Package browser defines an interface for interacting with web browsers to import bookmarks.
blink
Package blink provides functionalities for importing bookmarks from Blink-based web browsers like Chromium, Chrome, and Edge.
Package blink provides functionalities for importing bookmarks from Blink-based web browsers like Chromium, Chrome, and Edge.
gecko
Package gecko provides functionalities for importing bookmarks from Gecko-based web browsers like Firefox.
Package gecko provides functionalities for importing bookmarks from Gecko-based web browsers like Firefox.
paths
Package browserpath provides functions to generate platform-specific paths for browser profiles and bookmark files.
Package browserpath provides functions to generate platform-specific paths for browser profiles and bookmark files.
Package terminal provides utilities for interacting with the command-line terminal.
Package terminal provides utilities for interacting with the command-line terminal.

Jump to

Keyboard shortcuts

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