app

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SettingsDir is the directory where settings are stored
	SettingsDir = ".sshx"
	// SettingsFile is the name of the settings file
	SettingsFile = "settings.json"
	// DefaultHostType is the default system type assigned to a host
	DefaultHostType = "linux"
)

Variables

View Source
var ErrReported = errors.New("result already reported")

ErrReported signals that a structured (JSON) result has already been written to stdout, so the entry point should exit without printing anything further.

View Source
var ErrUsage = errors.New("usage displayed")

ErrUsage is returned when only the usage information was printed.

View Source
var Version = "dev"

Version is the sshx build version, set by the main package at startup (injected via -ldflags). Defaults to "dev" for go test / go run builds.

Functions

func AddHost added in v0.0.10

func AddHost(settings *Settings, host HostConfig) error

AddHost adds a new host to settings

func GetSettingsDir added in v0.0.10

func GetSettingsDir() (string, error)

GetSettingsDir returns the path to the settings directory

func GetSettingsPath added in v0.0.10

func GetSettingsPath() (string, error)

GetSettingsPath returns the path to the settings file

func HandleHostManagement added in v0.0.10

func HandleHostManagement(config *sshclient.Config) error

HandleHostManagement handles host management commands

func HandlePasswordManagement

func HandlePasswordManagement(config *sshclient.Config) error

HandlePasswordManagement handles all password management operations.

func HandleTransfer added in v0.0.13

func HandleTransfer(config *sshclient.Config) (err error)

HandleTransfer performs a direct server-to-server file transfer. It opens SSH connections to both the source and destination hosts and streams data between them through the local machine without touching local disk.

func ParseArgs

func ParseArgs(args []string) *sshclient.Config

ParseArgs parses command-line arguments and returns a Config.

func PrintUsage

func PrintUsage()

PrintUsage prints the usage information for the sshx command.

func RemoveHost added in v0.0.10

func RemoveHost(settings *Settings, name string) error

RemoveHost removes a host from settings by name

func Run

func Run(args []string) (err error)

Run executes the CLI using the provided arguments (typically os.Args).

func SaveSettings added in v0.0.10

func SaveSettings(settings *Settings) error

SaveSettings saves settings to the settings file

func UpdateHost added in v0.0.10

func UpdateHost(settings *Settings, host HostConfig) error

UpdateHost updates an existing host configuration

func ValidateHostConfig added in v0.0.10

func ValidateHostConfig(host *HostConfig) error

ValidateHostConfig validates a host configuration

Types

type ExitError added in v0.0.10

type ExitError struct {
	Code int
}

ExitError carries a remote command's exit status so the process can exit with the same code (mirroring the behavior of the ssh client).

func (*ExitError) Error added in v0.0.10

func (e *ExitError) Error() string

type HostConfig added in v0.0.10

type HostConfig struct {
	Name        string `json:"name"`                   // Host name (unique identifier)
	Description string `json:"description,omitempty"`  // Description
	Host        string `json:"host"`                   // IP or hostname
	Port        string `json:"port,omitempty"`         // Port (default: 22)
	User        string `json:"user,omitempty"`         // Username (default: master)
	Key         string `json:"key,omitempty"`          // SSH private key path (optional, overrides global key)
	PasswordKey string `json:"password_key,omitempty"` // Password key name (optional)
	Type        string `json:"type,omitempty"`         // System type (linux/windows/macos)
}

HostConfig represents a configured host

func GetHost added in v0.0.10

func GetHost(settings *Settings, name string) (*HostConfig, error)

GetHost retrieves a host configuration by name

func ListHosts added in v0.0.10

func ListHosts(settings *Settings) []HostConfig

ListHosts returns all configured hosts

type Settings added in v0.0.10

type Settings struct {
	Key   string       `json:"key,omitempty"` // Default SSH key path (e.g., ~/.ssh/id_rsa)
	Hosts []HostConfig `json:"hosts"`         // List of configured hosts
}

Settings represents the user-level configuration

func LoadSettings added in v0.0.10

func LoadSettings() (*Settings, error)

LoadSettings loads settings from the settings file

Jump to

Keyboard shortcuts

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