self

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package self implements self-management commands for nssh.

Index

Constants

View Source
const ShellIntegrationMarker = "# nssh shell integration"

ShellIntegrationMarker is the comment marker used to identify nssh shell integration.

Variables

This section is empty.

Functions

func AbbreviatePath

func AbbreviatePath(path string) string

AbbreviatePath replaces home directory with ~ for display.

func CheckDependencies

func CheckDependencies() (bool, bool)

CheckDependencies returns (allRequired, allOptional) booleans.

func DirExists

func DirExists(path string) bool

DirExists returns true if the path exists and is a directory.

func FileExists

func FileExists(path string) bool

FileExists returns true if the path exists and is a regular file.

func FindBinary

func FindBinary() string

FindBinary returns the full path to the nssh binary, or empty string if not found.

func FindProjectRoot

func FindProjectRoot() string

FindProjectRoot looks for go.mod starting from cwd and going up. Returns the directory containing go.mod, or empty string if not found.

func InstalledDependencyPaths added in v0.2.3

func InstalledDependencyPaths() []string

InstalledDependencyPaths returns paths to dependencies installed by nssh in ~/.local/bin. Only returns paths that actually exist.

func NewCfgCmd added in v0.2.3

func NewCfgCmd() *cobra.Command

NewCfgCmd creates the cfg subcommand.

func NewInitCmd

func NewInitCmd() *cobra.Command

NewInitCmd creates the init subcommand.

func NewPivCmd

func NewPivCmd() *cobra.Command

NewPivCmd creates a stub piv command for non-hardware builds.

func NewReinstallCmd

func NewReinstallCmd() *cobra.Command

NewReinstallCmd creates the reinstall subcommand.

func NewRekeyCmd

func NewRekeyCmd() *cobra.Command

NewRekeyCmd creates the rekey command.

func NewResetCmd

func NewResetCmd() *cobra.Command

NewResetCmd creates the reset subcommand.

func NewStatusCmd

func NewStatusCmd() *cobra.Command

NewStatusCmd creates the status subcommand.

func NewUninstallCmd

func NewUninstallCmd() *cobra.Command

NewUninstallCmd creates the uninstall subcommand.

func NewVersionCmd

func NewVersionCmd() *cobra.Command

NewVersionCmd creates the version subcommand (hidden, use -V flag instead).

func RunInitQuiet

func RunInitQuiet(dryRun bool) error

RunInitQuiet runs init with minimal output (used by reinstall). Only refreshes shell integration, does not touch credential protection.

func RunVersion

func RunVersion()

RunVersion prints version information and can be called from the root command's version flag handler.

func RunVersionExit

func RunVersionExit()

RunVersionExit prints version and exits. Used by the root command's persistent flag.

func SetRootCmd

func SetRootCmd(cmd *cobra.Command)

SetRootCmd sets the root command (called from main for completion generation).

func SetVersion

func SetVersion(v, c, d, f string)

SetVersion sets the version info (called from main).

Types

type Dependency

type Dependency struct {
	Name     string         // Binary name
	Required bool           // true = required, false = optional
	Purpose  string         // What it's used for
	Path     string         // Resolved path (empty if not found)
	GitHub   *GitHubRelease // GitHub release info (nil if package manager only)
}

Dependency represents an external binary dependency.

func Dependencies

func Dependencies() []Dependency

Dependencies returns the list of external dependencies.

func (Dependency) PackageName

func (d Dependency) PackageName(pm *PackageManager) string

PackageName returns the package name for a dependency on a given package manager.

type GitHubRelease added in v0.2.3

type GitHubRelease struct {
	Owner string // e.g., "asciinema"
	Repo  string // e.g., "asciinema"
	// AssetPattern is a function that returns the asset filename for the current platform.
	// Takes (version, goos, goarch) and returns the asset filename.
	AssetPattern func(version, goos, goarch string) string
	// IsArchive indicates if the asset is a tar.gz archive that needs extraction.
	IsArchive bool
	// BinaryName is the name of the binary inside the archive (if different from dep name).
	BinaryName string
}

GitHubRelease contains info for downloading from GitHub releases.

type HardwareType

type HardwareType string

HardwareType represents a specific hardware security implementation.

const (
	HardwareTypePIV HardwareType = "piv" // YubiKey PIV applet

)

Hardware security implementation types.

func AvailableHardwareTypes

func AvailableHardwareTypes() []HardwareType

AvailableHardwareTypes returns the list of available hardware types. This will expand as more implementations are added.

type InitOptions

type InitOptions struct {
	SkipShell bool // skip shell integration entirely
	DryRun    bool // preview mode, no changes made
	Yes       bool // auto-confirm all prompts
	Quiet     bool // minimal output (for reinstall)
}

InitOptions configures the behavior of runInit.

type PackageManager

type PackageManager struct {
	Name       string   // e.g., "brew", "apt", "dnf", "pacman"
	InstallCmd []string // e.g., ["brew", "install"]
	Path       string   // resolved path to the package manager
}

PackageManager represents a system package manager.

func DetectPackageManager

func DetectPackageManager() *PackageManager

DetectPackageManager finds an available package manager.

func (*PackageManager) InstallCommand

func (pm *PackageManager) InstallCommand(packages ...string) []string

InstallCommand returns the full command to install a package.

type ResetSummary

type ResetSummary struct {
	ConfigDir      string
	DataDir        string
	StateDir       string
	HostCount      int
	ContextCount   int
	RecordingCount int
	TotalBytes     int64
}

ResetSummary holds statistics about what would be deleted.

type SecurityMode

type SecurityMode string

SecurityMode represents the top-level security mode choice.

const (
	SecurityModeSoftware SecurityMode = "software" // Software-based encryption with passphrase
	SecurityModeHardware SecurityMode = "hardware" // Hardware security module (e.g., YubiKey)
)

Security modes for credential protection.

type SecurityState

type SecurityState int

SecurityState represents the current state of credential protection.

const (
	StateNewInstall           SecurityState = iota // No existing credentials
	StateLegacyNeedsMigration                      // Unprotected legacy storage detected
	StateAlreadyInitialized                        // Protected storage already configured
)

Security states for credential protection detection.

type ShellInfo

type ShellInfo struct {
	Name   string // "bash", "zsh", "fish", or "unknown"
	RCFile string // Path to the shell's rc file
}

ShellInfo contains detected shell information.

func DetectShell

func DetectShell() ShellInfo

DetectShell detects the user's shell and returns appropriate rc file path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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