Documentation
¶
Overview ¶
Package self implements self-management commands for nssh.
Index ¶
- Constants
- func AbbreviatePath(path string) string
- func CheckDependencies() (bool, bool)
- func DirExists(path string) bool
- func FileExists(path string) bool
- func FindBinary() string
- func FindProjectRoot() string
- func InstalledDependencyPaths() []string
- func NewCfgCmd() *cobra.Command
- func NewInitCmd() *cobra.Command
- func NewPivCmd() *cobra.Command
- func NewReinstallCmd() *cobra.Command
- func NewRekeyCmd() *cobra.Command
- func NewResetCmd() *cobra.Command
- func NewStatusCmd() *cobra.Command
- func NewUninstallCmd() *cobra.Command
- func NewVersionCmd() *cobra.Command
- func RunInitQuiet(dryRun bool) error
- func RunVersion()
- func RunVersionExit()
- func SetRootCmd(cmd *cobra.Command)
- func SetVersion(v, c, d, f string)
- type Dependency
- type GitHubRelease
- type HardwareType
- type InitOptions
- type PackageManager
- type ResetSummary
- type SecurityMode
- type SecurityState
- type ShellInfo
Constants ¶
const ShellIntegrationMarker = "# nssh shell integration"
ShellIntegrationMarker is the comment marker used to identify nssh shell integration.
Variables ¶
This section is empty.
Functions ¶
func AbbreviatePath ¶
AbbreviatePath replaces home directory with ~ for display.
func CheckDependencies ¶
CheckDependencies returns (allRequired, allOptional) booleans.
func FileExists ¶
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 NewReinstallCmd ¶
NewReinstallCmd creates the reinstall subcommand.
func NewUninstallCmd ¶
NewUninstallCmd creates the uninstall subcommand.
func NewVersionCmd ¶
NewVersionCmd creates the version subcommand (hidden, use -V flag instead).
func RunInitQuiet ¶
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 ¶
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.