-
Notifications
You must be signed in to change notification settings - Fork 22
Implement brev copy command for file transfer #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e workspaces - Add new copy command in pkg/cmd/copy/copy.go following shell command patterns - Support bidirectional copying: local->remote and remote->local - Use scp for file transfer with workspace:path syntax parsing - Include workspace startup logic and SSH connection handling - Register command in SSH Commands section with aliases cp, scp - Add --host flag for copying to/from host machine vs container Co-Authored-By: Alec Fong <alecsanf@usc.edu>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Change copyLong description to use 'remote instance' - Update copyExample to use 'instance_name' in examples - Update error messages to reference 'instance path' format - Maintain consistency with Brev CLI terminology Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Validate local file exists before attempting workspace connection - Provide clear error message when file doesn't exist - Improves UX by failing fast on missing files - Only validates for upload operations (local-to-remote) Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- 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>
|
the success message looks like the following we need to put it on a new line and use the proper func to print. |
- Use t.Vprint with fmt.Sprintf instead of t.Vprintf to fix printf formatting errors - Ensures proper formatting of source, destination, and duration values - Addresses GitHub comment feedback about MISSING values in output Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Add s.Stop() call at end of pollUntil function - Add s.Stop() call in error path to ensure spinner is always stopped - Ensures success message appears on new line instead of same line as spinner - Addresses GitHub comment feedback about message formatting Co-Authored-By: Alec Fong <alecsanf@usc.edu>
|
what I meant by the new line is that I want to format like |
- Add fmt.Print("\n") before success message to ensure clean line separation
- Success message now appears on completely separate line after spinner stops
- Addresses GitHub comment feedback requesting proper formatting:
spinner line -> newline -> success message
- Follows pattern used in other commands like ollama
Co-Authored-By: Alec Fong <alecsanf@usc.edu>
can we support directories automatically? |
- Detect directories using os.Stat() and IsDir() - Add -r flag to scp when copying directories for uploads - Always use -r flag for downloads to handle both files and directories - Update validation messages to mention 'file or directory' - Update help text and examples to include directory copying - Addresses GitHub comment requesting directory support Resolves scp error: 'local "my-dir" is not a regular file' by automatically detecting directories and using recursive flag Co-Authored-By: Alec Fong <alecsanf@usc.edu>
Implement brev copy command for file transfer
Summary
This PR implements a new
brev copycommand that enables copying files between local machine and remote workspaces using scp, following the same patterns as the existingbrev shellcommand.Key features:
brev copy workspace:/remote/path /local/pathandbrev copy /local/path workspace:/remote/path--hostflag to copy to/from host machine instead of containercp,scpshell,open, etc.Implementation approach:
pkg/cmd/copy/copy.gofollowingshell.gopatternsstrings.Splitforworkspace:pathparsing (similar to portforward command)Review & Testing Checklist for Human
Critical items requiring manual verification:
brev stopthenbrev copy)workspace:/path:with:colons, paths with spaces)--hostflag correctly targets host vs containerRecommended test plan:
brev copy /local/test.txt myworkspace:/tmp/test.txtbrev copy myworkspace:/tmp/test.txt /local/downloaded.txt--hostflag behaviorDiagram
%%{ init : { "theme" : "default" }}%% graph TD main.go --> cmd.go["pkg/cmd/cmd.go<br/>(Minor Edit)"] cmd.go --> copy.go["pkg/cmd/copy/copy.go<br/>(Major Edit - New File)"] copy.go --> util.go["pkg/cmd/util/util.go<br/>(Context)"] copy.go --> shell.go["pkg/cmd/shell/shell.go<br/>(Context)"] copy.go --> refresh.go["pkg/cmd/refresh/refresh.go<br/>(Context)"] copy.go -.->|"reuses patterns"| shell.go copy.go -.->|"workspace resolution"| util.go copy.go -.->|"SSH refresh logic"| refresh.go cmd.go -->|"registers command"| copy.go subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
exec.Commandwith user input but sshAlias is validated through workspace resolutionshell.gopatterns for workspace handling, SSH setup, and error handlingLink to Devin run: https://app.devin.ai/sessions/e7fbaf33368343fc9d32002721a55ea0
Requested by: Alec Fong (@theFong)