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 ¶
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 ¶
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 接管,以确保取消能够唤醒阻塞读取。