Skip to content

Add login and port override flags to wsh ssh#3045

Merged
sawka merged 4 commits intomainfrom
copilot/add-port-and-user-options
Mar 12, 2026
Merged

Add login and port override flags to wsh ssh#3045
sawka merged 4 commits intomainfrom
copilot/add-port-and-user-options

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

wsh ssh already accepted user@host[:port], but there was no way to override the parsed user or port from flags. This change adds -l/--login and -p/--port, with flag values taking precedence over the target string.

  • CLI surface

    • Adds -l, --login to set the remote user
    • Adds -p, --port to set the remote port
  • Override behavior

    • Normalizes the final SSH target before connect/block metadata updates
    • Reuses the existing shared SSH target parser/formatter, so overrides apply consistently to:
      • the connection request
      • the stored connection string shown in block metadata
  • Coverage

    • Adds focused unit tests for:
      • login override
      • port override
      • combined login + port override
      • bare host inputs
      • invalid target handling when overrides are requested

Example:

wsh ssh -l foo root@bar.com
# => connects/stores foo@bar.com

wsh ssh -p 2222 root@bar.com:2022
# => connects/stores root@bar.com:2222

wsh ssh -l foo -p 2200 bar.com
# => connects/stores foo@bar.com:2200

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits March 12, 2026 21:40
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Copilot AI changed the title [WIP] Add -p and -l options for port and user override Add login and port override flags to wsh ssh Mar 12, 2026
Copilot AI requested a review from sawka March 12, 2026 21:43
@sawka sawka marked this pull request as ready for review March 12, 2026 21:50
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 12, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • cmd/wsh/cmd/wshcmd-ssh.go - Added --login and --port flags for SSH connection override
  • cmd/wsh/cmd/wshcmd-ssh_test.go - New test file with comprehensive test coverage

The implementation adds two new CLI flags (--login / -l and --port / -p) to the wsh ssh command, allowing users to override the login username and port when connecting to remote hosts. The code follows proper patterns:

  • Uses cobra's ExactArgs(1) validation to ensure the SSH target argument is provided
  • Applies overrides before using the argument for connection setup
  • Properly handles errors from remote.ParseOpts()
  • Includes comprehensive test coverage for various edge cases (no overrides, login only, port only, both, bare hosts, invalid targets)

@sawka sawka merged commit b6884b2 into main Mar 12, 2026
6 checks passed
@sawka sawka deleted the copilot/add-port-and-user-options branch March 12, 2026 22:01
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.

2 participants