Skip to content

MARSOHS-2747: accept --local-file on harness-runtime download - #2115

Open
nveerdixit wants to merge 6 commits into
digitalocean:mainfrom
nveerdixit:marsohs-2747-download-local-file
Open

nveerdixit wants to merge 6 commits into
digitalocean:mainfrom
nveerdixit:marsohs-2747-download-local-file

Conversation

@nveerdixit

Copy link
Copy Markdown
Contributor

Summary

doctl harness-runtime upload names the local path --local-file. download named the same thing --save-to. A user who had just run upload --local-file ./x.txt naturally tried download --local-file ./x.txt and got Error: unknown flag: --local-file.

download now accepts --local-file as a second spelling of --save-to:

doctl harness-runtime download my-session --workspace-path x.txt --local-file ./x.txt   # now works
doctl harness-runtime download my-session --workspace-path x.txt --save-to ./x.txt      # unchanged

How

  • This uses the mechanism behind the existing --file alias for --spec: the command's flag normalize function maps local-file to save-to. No new flag is registered.
  • --save-to stays the name in help output and in the missing-flag error, so existing scripts and docs stay correct.
  • The mapping is now a small helper, acceptFlagAlias(cmd, alias, canonical). acceptFileAliasFor calls it, with unchanged behaviour.
  • The download help text says --local-file also works.

Notes

  • Passing both spellings behaves like passing one flag twice: the last value wins. This is the same as --spec / --file.
  • A pflag flag set holds one normalize function, so a command can carry one such alias. The helper's comment says so.
  • Unchanged: upload, doctl microvm upload/download (same pair of names, different command group) and the in-chat /download command.

Testing

TestAgentsDownload_LocalFileIsAliasForSaveTo parses the real download command and checks four things:

  • --local-file and --save-to each reach the value RunAgentsDownload reads.
  • --save-to stays the canonical flag name.
  • With neither given, the pre-run required-flag check reports save-to.

I also confirmed that swapping the helper's two arguments makes the test fail.

go test ./commands/ ./do/ passes except TestRegistryLogout, which also fails on unmodified main in my environment (it needs the OS keychain).

Refs: MARSOHS-2747

🤖 Generated with Claude Code

upload names the local path --local-file while download names it --save-to, so
the symmetric guess failed with "unknown flag". download now accepts
--local-file as a second spelling of --save-to through the flag set's normalize
function, the same way --file is accepted for --spec. --save-to stays canonical
in help and keeps its required check; the help text mentions the alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nveerdixit

Copy link
Copy Markdown
Contributor Author

Live check. upload then download --local-file; the downloaded file matches. --save-to still works, and omitting both still reports --save-to as required.

local-file

sanpj2292
sanpj2292 previously approved these changes Nov 25, 2026

@sanpj2292 sanpj2292 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One non-blocking nit:

  • acceptFlagAlias calls SetNormalizeFunc, and a command has only one normalize function, so a second call on the same command silently replaces the first alias. That's safe today, because download has no other alias, and the doc comment says so. If a second alias is ever needed, a small map-based version (alias → canonical) would avoid the trap.

@sdharavath sdharavath left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

SSharma-10
SSharma-10 previously approved these changes Nov 25, 2026
@SSharma-10

Copy link
Copy Markdown
Contributor

please resolve the merge conflicts

nveerdixit and others added 2 commits November 26, 2026 12:21
A flag set has one normalize function, so a second acceptFlagAlias call on
the same command replaced the first alias. Wrap the previous function
instead, so a command can take several aliases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@nveerdixit
nveerdixit dismissed stale reviews from SSharma-10 and sanpj2292 via a671bbe November 26, 2026 06:53
@nveerdixit

Copy link
Copy Markdown
Contributor Author

Merged main in b778895 (normal merge, no rebase). Git resolved commands/agents.go and commands/agents_help.go on its own, so no hand edits were needed.

@sanpj2292 I took the nit in a671bbe. acceptFlagAlias now wraps the existing normalize func instead of replacing it, so a second alias on one command no longer drops the first. No command has two aliases today (download has --local-file; validate, update and create have --file), so nothing changes in behavior. TestAcceptFlagAlias_SecondAliasKeepsFirst covers two aliases on one command.

go vet ./commands/ passes. go test ./commands/ passes except TestRegistryLogout, which fails on a local keychain issue.

…-local-file

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	commands/agents_test.go
@nveerdixit

Copy link
Copy Markdown
Contributor Author

main moved again (#2153), so I merged it once more in df80212. commands/agents_test.go conflicted because both sides added tests at the end of the file. I kept both sets of tests. main added no new normalize funcs. GitHub now reports the PR as mergeable. go vet and the focused tests pass. go test ./commands/ passes except TestRegistryLogout (local keychain).

@SSharma-10

Copy link
Copy Markdown
Contributor

@nveerdixit please resolve the merge conflicts

…-local-file

Co-authored-by: Cursor <cursoragent@cursor.com>
@nveerdixit

Copy link
Copy Markdown
Contributor Author

@SSharma-10 Resolved. I merged current main (424f37f, which includes #2111, #2112 and #2157) into the branch in merge commit 75497a5. The only conflict was in commands/agents_test.go, where both sides had added tests at the same place. I kept both: the --local-file alias tests from this PR and TestRunAgentsCreate_JSONKeepsPermissionLineOffStdout from main. gofmt, go vet ./commands/ and go test ./commands/ pass locally. GitHub now reports the PR as mergeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants