Skip to content

Commit a573941

Browse files
Add completion message with timing for copy operations
- Track transfer duration using time.Now() and time.Since() - Display success message showing source → destination with timing - Use terminal.Green() for colored success output following CLI patterns - Updated runSCP function signature to accept terminal parameter - Improves UX by confirming successful transfers with clear feedback Co-Authored-By: Alec Fong <alecsanf@usc.edu>
1 parent ca76adf commit a573941

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

pkg/cmd/copy/copy.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func runCopyCommand(t *terminal.Terminal, cstore CopyStore, source, dest string,
8787

8888
_ = writeconnectionevent.WriteWCEOnEnv(cstore, workspace.DNS)
8989

90-
err = runSCP(sshName, localPath, remotePath, isUpload)
90+
err = runSCP(t, sshName, localPath, remotePath, isUpload)
9191
if err != nil {
9292
return breverrors.WrapAndTrace(err)
9393
}
@@ -194,20 +194,30 @@ func parseWorkspacePath(path string) (workspace, filePath string, err error) {
194194
return parts[0], parts[1], nil
195195
}
196196

197-
func runSCP(sshAlias, localPath, remotePath string, isUpload bool) error {
197+
func runSCP(t *terminal.Terminal, sshAlias, localPath, remotePath string, isUpload bool) error {
198198
var scpCmd *exec.Cmd
199+
var source, dest string
200+
201+
startTime := time.Now()
199202

200203
if isUpload {
201204
scpCmd = exec.Command("scp", localPath, fmt.Sprintf("%s:%s", sshAlias, remotePath)) //nolint:gosec //sshAlias is validated workspace identifier
205+
source = localPath
206+
dest = fmt.Sprintf("%s:%s", sshAlias, remotePath)
202207
} else {
203208
scpCmd = exec.Command("scp", fmt.Sprintf("%s:%s", sshAlias, remotePath), localPath) //nolint:gosec //sshAlias is validated workspace identifier
209+
source = fmt.Sprintf("%s:%s", sshAlias, remotePath)
210+
dest = localPath
204211
}
205212

206213
output, err := scpCmd.CombinedOutput()
207214
if err != nil {
208215
return breverrors.WrapAndTrace(fmt.Errorf("scp failed: %s\nOutput: %s", err.Error(), string(output)))
209216
}
210217

218+
duration := time.Since(startTime)
219+
t.Vprintf(t.Green("✓ Successfully copied %s → %s (%v)\n"), source, dest, duration.Round(time.Millisecond))
220+
211221
return nil
212222
}
213223

0 commit comments

Comments
 (0)