cli

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Overview

Package cli defines the sshush command-line interface using Cobra. Commands include start, stop, list, add, remove, reload, create, edit, export, find, tui, completion, and version. Config is loaded in root PersistentPreRunE.

Index

Constants

This section is empty.

Variables

View Source
var ErrPassphrasesDoNotMatch = errors.New("passphrases do not match")

ErrPassphrasesDoNotMatch is returned when confirmation does not match the first entry.

Functions

func AppendKeysTo

func AppendKeysTo(keyring sshagent.Agent, out *style.Output, socketPath, vaultPath string) error

AppendKeysTo appends the keyring's key lines to an existing Output builder. When socketPath and vaultPath are set and the agent reports the vault locked via the vault-locked extension, shows a vault-specific message instead of the generic empty key list.

func ClearBytes added in v0.0.7

func ClearBytes(b []byte)

ClearBytes overwrites b with zeros. Use after handling sensitive passphrase material.

func CopyToClipboard added in v0.0.7

func CopyToClipboard(text string) error

CopyToClipboard writes text to the system clipboard. Uses wl-copy (Wayland), xclip (X11), or pbcopy (macOS). Returns an error if the platform is unsupported or the command fails.

func Execute

func Execute() error

Execute runs the root command and handles error display; StyledError is printed via PrintErr.

func ListKeys

func ListKeys(keyring sshagent.Agent) error

ListKeys prints the keyring's keys to stdout.

func ListKeysSnapshotTo

func ListKeysSnapshotTo(keys []*sshagent.Key, w io.Writer) error

ListKeysSnapshotTo writes a pre-fetched key list to w.

func ListKeysTo

func ListKeysTo(keyring sshagent.Agent, w io.Writer) error

ListKeysTo writes the keyring's keys to w. Used for tests.

func LoadMergedConfig

func LoadMergedConfig(configPath string, overrides LoadOverrides) (config.Config, error)

LoadMergedConfig loads config from path and applies overrides. If the config file is missing but the user supplied socket or key overrides, an empty config is used so the command can still run (e.g. using SSH_AUTH_SOCK for socket).

func NewRootCommand

func NewRootCommand() *cobra.Command

NewRootCommand returns the root cobra command for sshush with flags and PersistentPreRunE wired.

func ReadPassphraseWithConfirm added in v0.0.7

func ReadPassphraseWithConfirm(firstPrompt, confirmPrompt string) ([]byte, error)

ReadPassphraseWithConfirm prompts twice (with two blank lines between, matching vault init UX) and returns the passphrase if both entries match. The confirmation buffer is cleared before return. On mismatch, both buffers are cleared. Caller should ClearBytes the returned slice when done.

Types

type LoadOverrides

type LoadOverrides struct {
	SocketPath  string
	KeyPaths    []string
	SocketSet   bool
	KeyPathsSet bool
}

LoadOverrides holds CLI flag values and whether each was set (so we only override when set).

Jump to

Keyboard shortcuts

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