Skip to content

feat: add one shot commands to the coder ssh command #17779

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

Merged
merged 11 commits into from
May 16, 2025

Conversation

brettkolodny
Copy link
Contributor

@brettkolodny brettkolodny commented May 12, 2025

Closes #2154

Warning

The tests in this PR were co-authored by AI

@coder coder deleted a comment May 12, 2025
Comment on lines +98 to +107
func(next serpent.HandlerFunc) serpent.HandlerFunc {
return func(i *serpent.Invocation) error {
got := len(i.Args)
if got < 1 {
return xerrors.New("expected the name of a workspace")
}

return next(i)
}
},
Copy link
Member

Choose a reason for hiding this comment

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

Keep this here, but we should add a serpent MW for RequireMinArgs(n). I also wanted it at some point.

cli/ssh.go Outdated
Use: "ssh <workspace>",
Short: "Start a shell into a workspace",
Use: "ssh <workspace> [command]",
Short: "Start a shell into a workspace or run a command",
Long: "This command does not have full parity with the standard SSH command. For users who need the full functionality of SSH, create an ssh configuration with `coder config-ssh`.",
Copy link
Member

Choose a reason for hiding this comment

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

ssh <workspace> ls -la works, but coder ssh <workspace> ls -la does not. I don't think we have to fix this, but we should have an example on how to pass flags. It is common unix stuff, but worth throwing in here imo.

Suggested change
Long: "This command does not have full parity with the standard SSH command. For users who need the full functionality of SSH, create an ssh configuration with `coder config-ssh`.",
Long: "This command does not have full parity with the standard SSH command. For users who need the full functionality of SSH, create an ssh configuration with `coder config-ssh`.\n" +
FormatExamples(
Example{
Description: "Use `--` to separate and pass flags directly to the command executed via SSH.",
Command: "coder ssh <workspace> -- ls -la",
},
),

@brettkolodny brettkolodny merged commit 2cd3f99 into main May 16, 2025
36 checks passed
@brettkolodny brettkolodny deleted the bett-feat/add-ssh-one-shot-command branch May 16, 2025 14:09
@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to for running commands in workspace via coder ssh workspace [command]
2 participants