cmd

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 52 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyGeneralOptions added in v0.16.0

func ApplyGeneralOptions(opts *SshOptions, optionStrings []string, flags *pflag.FlagSet) error

ApplyGeneralOptions parses non-multiplexing OpenSSH options from -o (such as Port, User, IdentityFile, ProxyJump) and applies them to SshOptions if they were not already explicitly set via primary CLI flags.

func ErrorAlreadyReported added in v0.16.0

func ErrorAlreadyReported(err error) bool

ErrorAlreadyReported reports whether err's message was already written to stderr in its final form and must not be printed a second time.

func Execute

func Execute() (err error)

func ExecuteControlCommand added in v0.16.0

func ExecuteControlCommand(ctx context.Context, o *SshOptions) error

ExecuteControlCommand executes the -O subcommand on the active master process.

func ExitCodeFromError added in v0.16.0

func ExitCodeFromError(err error) (int, bool)

ExitCodeFromError extracts the exit code if err implements ExitCoder, or unwraps cryptoSSH.ExitError / ssh.CommandExitError.

func HasStandardOutputError added in v0.15.0

func HasStandardOutputError(err error) bool

HasStandardOutputError limits suppression to failures of process standard streams. Walk every joined cause: an independent log error must not hide a simultaneous standard-stream failure, or vice versa trigger suppression.

func NewCmdCredential added in v0.12.0

func NewCmdCredential() *cobra.Command

NewCmdCredential 创建凭据管理根命令

func NewCmdExec

func NewCmdExec() *cobra.Command

func NewCmdIdentity

func NewCmdIdentity() *cobra.Command

func NewCmdIdentityAdd

func NewCmdIdentityAdd() *cobra.Command

func NewCmdIdentityCredential added in v0.12.0

func NewCmdIdentityCredential() *cobra.Command

NewCmdIdentityCredential 创建 identity credential 子命令

func NewCmdIdentityDelete

func NewCmdIdentityDelete() *cobra.Command

func NewCmdIdentityEdit

func NewCmdIdentityEdit() *cobra.Command

func NewCmdIdentityList

func NewCmdIdentityList() *cobra.Command

func NewCmdInit added in v0.11.0

func NewCmdInit() *cobra.Command

NewCmdInit creates the command that initializes local XOps configuration.

func NewCmdMcp

func NewCmdMcp() *cobra.Command

func NewCmdPlay added in v0.9.0

func NewCmdPlay() *cobra.Command

func NewCmdScp

func NewCmdScp() *cobra.Command

func NewCmdSftp

func NewCmdSftp() *cobra.Command

func NewCmdSsh

func NewCmdSsh() *cobra.Command

func NewCmdTui added in v0.3.0

func NewCmdTui() *cobra.Command

Types

type ControlExitError added in v0.16.0

type ControlExitError struct {
	Code    int
	Message string
	// Reported marks a message already written to stderr in its final
	// OpenSSH-compatible form, so the top-level handler must not print it again.
	// Usage failures raised while parsing flags are not reported yet.
	Reported bool
}

ControlExitError represents an OpenSSH control command exit status.

func (*ControlExitError) Error added in v0.16.0

func (e *ControlExitError) Error() string

func (*ControlExitError) ExitCode added in v0.16.0

func (e *ControlExitError) ExitCode() int

type DoctorCheckItem added in v0.12.0

type DoctorCheckItem struct {
	Name    string
	Status  string // "OK", "WARN", "FAIL"
	Message string
}

DoctorCheckItem 表示单项检查结果

type ExecOptions

type ExecOptions struct {
	SshOptions
	HostFile    string
	ShellFile   string
	Command     string
	Tag         string
	Exclude     []string
	TaskCount   int
	Interactive bool
	Stream      bool
	OutDir      string

	ScriptArgs []string
	// contains filtered or unexported fields
}

func NewExecOptions

func NewExecOptions() *ExecOptions

func (*ExecOptions) Complete

func (o *ExecOptions) Complete(cmd *cobra.Command, args []string) error

func (*ExecOptions) Run

func (o *ExecOptions) Run() error

func (*ExecOptions) RunContext added in v0.12.0

func (o *ExecOptions) RunContext(ctx context.Context) (retErr error)

RunContext executes the command on all selected hosts and propagates caller cancellation.

func (*ExecOptions) Validate

func (o *ExecOptions) Validate() error

type ExitCoder added in v0.16.0

type ExitCoder interface {
	ExitCode() int
}

ExitCoder is implemented by errors that specify a process exit code.

type InitOptions added in v0.11.0

type InitOptions struct {
	ConfigPath       string
	KeyPath          string
	SSHConfigPath    string
	SSHConfigChanged bool
	SkipSSHImport    bool
}

InitOptions contains the filesystem-only settings for xops init.

func NewInitOptions added in v0.11.0

func NewInitOptions() *InitOptions

NewInitOptions creates initialization options with the default OpenSSH path.

func (*InitOptions) Run added in v0.11.0

func (o *InitOptions) Run() (initResult, error)

Run creates the local configuration and imports concrete OpenSSH hosts. It never performs network operations and never overwrites existing nodes.

func (*InitOptions) RunContext added in v0.12.0

func (o *InitOptions) RunContext(ctx context.Context) (initResult, error)

RunContext creates local configuration while preserving caller cancellation through durable configuration writes.

type PathInfo

type PathInfo struct {
	IsRemote bool
	User     string
	Host     string
	Port     uint16
	Path     string
}

type PlayOptions added in v0.9.0

type PlayOptions struct {
	FilePath    string
	Vars        []string // 格式: "key=value"
	Concurrency uint
	DryRun      bool
	Limit       string // 逗号分隔的节点名称,覆盖 Playbook 的 targets
	Sudo        bool
	Out         io.Writer
}

PlayOptions 保存 xops play 命令的所有选项

func NewPlayOptions added in v0.9.0

func NewPlayOptions() *PlayOptions

func (*PlayOptions) Run added in v0.9.0

func (o *PlayOptions) Run() error

Run 执行 Playbook。

func (*PlayOptions) RunContext added in v0.12.0

func (o *PlayOptions) RunContext(ctx context.Context) (retErr error)

RunContext executes the Playbook and propagates caller cancellation through target resolution, SSH connections, and step execution.

type SCPOutputError added in v0.15.0

type SCPOutputError struct {
	Stream string
	Err    error
}

SCPOutputError records failed auxiliary SCP output. The CLI must not try to print this error to standard streams again: they may share a blocked sink. Unwrap preserves the original I/O and cancellation errors for API callers.

func (*SCPOutputError) Error added in v0.15.0

func (e *SCPOutputError) Error() string

func (*SCPOutputError) Unwrap added in v0.15.0

func (e *SCPOutputError) Unwrap() error

type SSHControlFlags added in v0.16.0

type SSHControlFlags struct {
	MasterCount int      // -M count: 1 -> ControlMaster=yes, >=2 -> ControlMaster=ask
	ControlPath string   // -S <path> or "none"
	CtlCmd      string   // -O <command>
	Options     []string // -o Key=Value options
}

SSHControlFlags encapsulates OpenSSH-compatible multiplexing and session control flags.

func (*SSHControlFlags) ControlCommandWithoutTarget added in v0.16.0

func (f *SSHControlFlags) ControlCommandWithoutTarget() bool

ControlCommandWithoutTarget reports whether -O addresses an explicit -S socket and therefore does not need a destination argument. Without -S the socket can only be derived from a resolved node or an inventory/global default. Note that `-O proxy` opens a multiplexed session and always requires a target destination (matching OpenSSH `ssh -O proxy`), whereas `-O proxy-stream` and management queries can address `-S` directly without a target.

func (*SSHControlFlags) RegisterCommonFlags added in v0.16.0

func (f *SSHControlFlags) RegisterCommonFlags(cmd *cobra.Command)

RegisterCommonFlags registers -S and -o flags for scp, sftp, and exec.

func (*SSHControlFlags) RegisterSSHFlags added in v0.16.0

func (f *SSHControlFlags) RegisterSSHFlags(cmd *cobra.Command)

RegisterSSHFlags registers -M, -S, -o, -O flags for xops ssh.

func (*SSHControlFlags) ToSessionControlOptions added in v0.16.0

func (f *SSHControlFlags) ToSessionControlOptions() (adapter.SessionControlOptions, error)

ToSessionControlOptions converts SSHControlFlags into adapter.SessionControlOptions. Precedence: explicit CLI flags (-M, -S) override values parsed from -o options.

func (*SSHControlFlags) Validate added in v0.16.0

func (f *SSHControlFlags) Validate() error

Validate validates control flags and detects conflicting combinations.

type ScpOptions

type ScpOptions struct {
	SshOptions
	Recursive   bool
	Quiet       bool
	Verbose     bool
	Force       bool
	NoOverwrite bool
	TaskCount   int
	ThreadCount int
	Source      string
	Dest        string
	HostFile    string
	Tag         string
	Exclude     []string
	// contains filtered or unexported fields
}

func NewScpOptions

func NewScpOptions() *ScpOptions

func (*ScpOptions) Complete

func (o *ScpOptions) Complete(cmd *cobra.Command, args []string) error

func (*ScpOptions) Run

func (o *ScpOptions) Run() error

func (*ScpOptions) RunContext added in v0.12.0

func (o *ScpOptions) RunContext(ctx context.Context) (retErr error)

func (*ScpOptions) Validate

func (o *ScpOptions) Validate() error

type SftpOptions

type SftpOptions struct {
	SshOptions
	// contains filtered or unexported fields
}

func NewSftpOptions

func NewSftpOptions() *SftpOptions

func (*SftpOptions) Run

func (o *SftpOptions) Run() error

func (*SftpOptions) RunContext added in v0.12.0

func (o *SftpOptions) RunContext(ctx context.Context) (err error)

RunContext starts the interactive SFTP session and propagates caller cancellation.

func (*SftpOptions) Validate added in v0.16.0

func (o *SftpOptions) Validate() error

type SshOptions

type SshOptions struct {
	Host            string
	Port            uint16
	User            string
	Password        string
	PasswordStdin   bool
	OTP             string
	OTPStdin        bool
	IdentityFile    string
	Passphrase      string
	PassphraseStdin bool
	Remember        string
	Sudo            bool
	Alias           string
	JumpHost        string
	Tags            []string
	LocalForwards   []string
	RemoteForwards  []string
	NoCmd           bool
	DynamicForward  string
	BgRun           bool
	StdinRedirect   bool

	Target config.ConnectionTarget

	Command string

	NoLoginShell bool
	// contains filtered or unexported fields
}

func NewSshOptions

func NewSshOptions() *SshOptions

func (*SshOptions) Complete

func (o *SshOptions) Complete(cmd *cobra.Command, args []string) error

func (*SshOptions) Run

func (o *SshOptions) Run() error

func (*SshOptions) RunContext added in v0.12.0

func (o *SshOptions) RunContext(ctx context.Context) (err error)

RunContext starts the SSH operation and propagates caller cancellation.

func (*SshOptions) Validate

func (o *SshOptions) Validate() error

Directories

Path Synopsis
Package sftpshell implements the interactive presentation layer for SFTP.
Package sftpshell implements the interactive presentation layer for SFTP.

Jump to

Keyboard shortcuts

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