update
This commit is contained in:
+26
-48
@@ -1,23 +1,26 @@
|
||||
# SCP Plugin Walkthrough
|
||||
|
||||
This walkthrough adds a bundled `scp` plugin backed by existing SSH libraries:
|
||||
This walkthrough covers the bundled `scp` plugin, backed by existing SSH
|
||||
libraries:
|
||||
|
||||
- `paramiko` for SSH and SFTP directory listing
|
||||
- `scp` for file transfers
|
||||
|
||||
The implementation lives in [plugins/scp/__init__.py](plugins/scp/__init__.py).
|
||||
|
||||
## What The Plugin Does
|
||||
## What the plugin does
|
||||
|
||||
The SCP plugin mirrors the FTP walkthrough, but on top of SSH:
|
||||
- `search-file -plugin scp -instance <name> ...` lists remote files and folders over SFTP
|
||||
- plain `@N` on a folder drills into that directory
|
||||
- plain `@N` on a file runs `download-file -plugin scp -instance <name> -url ...`
|
||||
- `@N | add-file -instance ...` downloads first, then ingests the local temp file
|
||||
- `add-file -plugin scp -instance <name> -path ...` uploads a local file to the configured remote path
|
||||
|
||||
- `search-file -plugin scp -instance <name> ...` lists remote files and folders over SFTP.
|
||||
- plain `@N` on a folder drills into that directory.
|
||||
- plain `@N` on a file runs `download-file -plugin scp -instance <name> -url ...`.
|
||||
- `@N | add-file -instance ...` downloads first, then ingests the local temp file.
|
||||
- `add-file -plugin scp -instance <name> -path ...` uploads a local file to the configured remote path.
|
||||
## Example config
|
||||
|
||||
## Example Config
|
||||
Add one or more named SCP plugin instances to your config. The current stored
|
||||
key path remains `provider.scp.<instance>` for legacy compatibility:
|
||||
|
||||
```toml
|
||||
[provider.scp.work]
|
||||
@@ -42,39 +45,22 @@ timeout = 20
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- `work` and `archive` are instance names; use them with `-instance work` or `-instance archive`.
|
||||
- `work` and `archive` are instance names.
|
||||
- `host` and `username` are required for each instance to validate.
|
||||
- You can use password auth, key auth, or both.
|
||||
- `base_path` is both the default search root and the default upload directory.
|
||||
- You can browse configured instances from `.config plugins` in the CLI.
|
||||
|
||||
## Search Flow
|
||||
|
||||
List the configured base path:
|
||||
## Search flow
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "*"
|
||||
```
|
||||
|
||||
Search by filename:
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "invoice"
|
||||
```
|
||||
|
||||
Search another subtree with deeper recursion:
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "path:/srv/files/releases depth:2 *.zip"
|
||||
```
|
||||
|
||||
Show only folders:
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "path:/srv/files type:folder *"
|
||||
```
|
||||
|
||||
## Selection Flow
|
||||
## Selection flow
|
||||
|
||||
Folder rows are navigation rows:
|
||||
|
||||
@@ -83,7 +69,8 @@ search-file -plugin scp -instance work "*"
|
||||
@2
|
||||
```
|
||||
|
||||
File rows carry an explicit row action, so terminal selection downloads directly:
|
||||
File rows carry an explicit row action, so terminal selection downloads
|
||||
directly:
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "report"
|
||||
@@ -96,45 +83,36 @@ That expands to the equivalent of:
|
||||
download-file -plugin scp -instance work -url scp://ssh.example.com/srv/files/report.pdf
|
||||
```
|
||||
|
||||
## Download And Add-File Flow
|
||||
|
||||
Download into a local folder:
|
||||
## Download and add-file flow
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "report"
|
||||
@1 | download-file -path C:\Downloads
|
||||
```
|
||||
|
||||
Ingest a selected remote file into a configured instance backend:
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "report"
|
||||
@1 | add-file -instance tutorial
|
||||
```
|
||||
|
||||
Why this works:
|
||||
|
||||
- file rows advertise `_selection_action` for `download-file`
|
||||
- `add-file` selection replay inserts that provider download stage before ingest
|
||||
- the plugin also implements `resolve_pipe_result_download()` for provider-owned SCP rows
|
||||
- file rows also carry the chosen `instance`, so replay stays bound to the same SSH target
|
||||
- `add-file` selection replay inserts that plugin download stage before ingest
|
||||
- the plugin also implements `resolve_pipe_result_download()` for plugin-owned SCP rows
|
||||
- file rows carry the chosen `instance`, so replay stays bound to the same SSH target
|
||||
|
||||
## Upload Flow
|
||||
|
||||
Upload a local file to the configured remote `base_path`:
|
||||
## Upload flow
|
||||
|
||||
```powershell
|
||||
add-file -plugin scp -instance archive -path C:\Media\report.pdf
|
||||
```
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
The plugin uses SFTP for directory listing because SCP itself is a transfer protocol, not a browse/search protocol. That split keeps the provider simple:
|
||||
## Implementation notes
|
||||
|
||||
The plugin uses SFTP for directory listing because SCP itself is a transfer
|
||||
protocol, not a browse/search protocol. That split keeps the plugin simple:
|
||||
- browse and metadata via Paramiko SFTP
|
||||
- file transfer via the `scp` package
|
||||
|
||||
## Recommended Demo Commands
|
||||
## Recommended demo commands
|
||||
|
||||
```powershell
|
||||
search-file -plugin scp -instance work "*"
|
||||
|
||||
Reference in New Issue
Block a user