sftpshell

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package sftpshell implements the interactive presentation layer for SFTP.

Generic SFTP operations belong in pkg/sftp and return errors to their caller. This package translates command failures into interactive output so the REPL can continue, while prompt, output, and lifecycle failures are returned to the CLI command for final handling.

On Windows, remote exec/shell input uses an owned console handle with interruptible event reads. Input forwarding must finish before the next prompt takes ownership; normal EOF and cancellation are not command errors.

Index

Constants

This section is empty.

Variables

View Source
var ErrLineEditorClosed = errors.New("sftp line editor is closed")

ErrLineEditorClosed 表示 SFTP 行编辑器已经关闭。

Functions

This section is empty.

Types

type Option

type Option func(*Shell)

Option configures the interactive SFTP presentation layer.

func WithLogger

func WithLogger(l logger.DebugLogger) Option

WithLogger injects the concurrent-safe debug logger used for secondary UI diagnostics.

func WithNoOverwrite

func WithNoOverwrite(noOverwrite bool) Option

WithNoOverwrite makes transfer commands skip existing destinations without prompting. This policy belongs to the interactive presentation layer.

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell 定义交互式 SFTP 环境

func New

func New(ctx context.Context, client *sftp.Client, sshClient *ssh.Client, stdin io.Reader, stdout, stderr io.Writer, opts ...Option) (*Shell, error)

New creates a new interactive SFTP presentation layer. The line editor is created lazily by Run immediately before its first prompt, so Close never has to tear down an editor that has not begun reading. stdin 为 *os.File 时会复制文件描述符,使断线取消能够只关闭 Shell 自己的输入副本, 不影响进程级标准输入或其他终端使用者;其他输入必须实现 io.ReadCloser,且其生命周期 由 Shell 接管,以确保取消能够唤醒阻塞读取。

func (*Shell) Close

func (s *Shell) Close(ctx context.Context) error

Close makes the shell terminal, cancels an active Run, and waits for it to stop before closing the prompt and SFTP subsystem. Concurrent callers wait for the first close operation and observe the same result.

func (*Shell) Run

func (s *Shell) Run(ctx context.Context) (runErr error)

Run 启动交互式循环 (REPL)

Jump to

Keyboard shortcuts

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