diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-11 11:02:26 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-11 11:02:26 -0700 |
| commit | ccf7a336ed6c51fb4d79357be6549df13b5f2e2f (patch) | |
| tree | dceaf9ca8a4c0837f38dfe636ac31785d18d6be9 /ccp.go | |
| parent | aa52e78484b6ce69765f4c4adff27321b99b2251 (diff) | |
| download | ccp-ccf7a336ed6c51fb4d79357be6549df13b5f2e2f.tar.zst | |
Fix error messages and special case empty path
Diffstat (limited to 'ccp.go')
| -rw-r--r-- | ccp.go | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -173,6 +173,17 @@ func splitHostPath(target string) (string, string) { return target[:i], target[i+1:] } +func toFSPath(target string, sftpHosts map[string]*sftpfs.FS) cp.FSPath { + host, path := splitHostPath(target) + if host == "" { + return cp.FSPath{FS: osfs.FS{}, Path: path} + } + if path == "" { + path = "." + } + return cp.FSPath{FS: sftpHosts[host], Path: path} +} + func run() error { args := flag.Args() if len(args) < 2 { @@ -194,20 +205,9 @@ func run() error { } srcs := make([]cp.FSPath, len(srcTargets)) for i, tgt := range srcTargets { - host, path := splitHostPath(tgt) - if host == "" { - srcs[i] = cp.FSPath{FS: osfs.FS{}, Path: path} - } else { - srcs[i] = cp.FSPath{FS: sftpHosts[host], Path: path} - } - } - dstHost, dstPath := splitHostPath(dstTarget) - var dst cp.FSPath - if dstHost == "" { - dst = cp.FSPath{FS: osfs.FS{}, Path: dstPath} - } else { - dst = cp.FSPath{FS: sftpHosts[dstHost], Path: dstPath} + srcs[i] = toFSPath(tgt, sftpHosts) } + dst := toFSPath(dstTarget, sftpHosts) m := &model{ progress: progress.New(progress.WithDefaultGradient(), progress.WithoutPercentage()), copyingFiles: make(map[string]string), |
