feat: add sqlcmd open vscode and sqlcmd open ssms commands#688
feat: add sqlcmd open vscode and sqlcmd open ssms commands#688dlevy-msft-sql wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for opening Visual Studio Code and SQL Server Management Studio (SSMS) to work with SQL Server connections managed by sqlcmd, addressing the deprecation of Azure Data Studio. The implementation uses clipboard-based password sharing since both tools use sandboxed credential storage.
Changes:
- Adds
sqlcmd open vscodecommand that creates connection profiles in VS Code settings and auto-installs the MSSQL extension - Adds
sqlcmd open ssmscommand (Windows-only) that launches SSMS with pre-configured connection parameters - Implements cross-platform clipboard support for secure password sharing
- Includes comprehensive tests and documentation updates
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
cmd/modern/root/open.go |
Updates open command to include VSCode and SSMS subcommands |
cmd/modern/root/open/vscode.go |
Main VSCode command implementation with settings file manipulation |
cmd/modern/root/open/vscode_*.go |
Platform-specific VSCode implementations |
cmd/modern/root/open/ssms.go |
Main SSMS command implementation |
cmd/modern/root/open/ssms_*.go |
Platform-specific SSMS implementations (Fatal on non-Windows) |
cmd/modern/root/open/clipboard.go |
Helper function for clipboard-based password sharing |
cmd/modern/root/open/*_test.go |
Comprehensive test coverage for new commands |
internal/tools/tool/vscode*.go |
VSCode tool detection and configuration |
internal/tools/tool/ssms*.go |
SSMS tool detection and configuration |
internal/pal/clipboard*.go |
Cross-platform clipboard implementation using native APIs |
internal/tools/tools.go |
Registers VSCode and SSMS tools |
README.md |
Adds clear documentation with usage examples |
.gitignore |
Adds /modern build artifact |
74dc09d to
b64f990
Compare
sqlcmd open vscode and sqlcmd open ssms commands04826fa to
eff9136
Compare
dd1141d to
675a0df
Compare
fa27800 to
f2b4a78
Compare
Add 'sqlcmd open vscode' and 'sqlcmd open ssms' subcommands that launch VS Code or SSMS pre-configured with the active sqlcmd context's connection. VS Code integration: - Creates/updates mssql.connections in VS Code settings.json - Preserves JSONC comments via surgical byte-level patchJSONCKey - Atomic temp-file-then-rename write to prevent corruption - Copies password to clipboard with security warning SSMS integration: - Launches SSMS with connection parameters via command line - Windows-only with platform stub for Unix Includes clipboard helpers, JSONC parser/patcher, platform abstractions, and comprehensive tests.
| options := cmdparser.CommandOptions{ | ||
| Use: "open", | ||
| Short: localizer.Sprintf("Open tools (e.g Azure Data Studio) for current context"), | ||
| Short: localizer.Sprintf("Open tools (e.g., Azure Data Studio, VS Code, SSMS) for current context"), |
| // Manager. | ||
| func (c *Ads) run() { | ||
| output := c.Output() | ||
| output.Warn(localizer.Sprintf("Azure Data Studio is being retired. This command will be removed in a future release.")) |
| "github.com/microsoft/go-sqlcmd/internal/tools" | ||
| ) | ||
|
|
||
| func (c *Ssms) DefineCommand(...cmdparser.CommandOptions) { |
| return nil | ||
| } | ||
|
|
||
| return fmt.Errorf("failed to copy to clipboard; tried xclip, xsel, wl-copy: %s", strings.Join(attempts, "; ")) |
There was a problem hiding this comment.
should this message be localizable?
| // System Insiders Install | ||
| // User non-Insiders install | ||
| // System non-Insiders install | ||
| func (t *VSCode) searchLocations() []string { |
There was a problem hiding this comment.
does vscode not write its location to the registry somewhere? Can't a user choose a custom location for it?
I feel like since vscode supports a URL handler we don't need to bother looking for it, and if the user tries to open vscode using sqlcmd without having installed vscode first, it's a fairly obvious user error that we don't need to spend time/code defending against.
| `Common7\IDE\Ssms.exe`, | ||
| } | ||
|
|
||
| func (t *SSMS) searchLocations() []string { |
Problem
sqlcmd open ads is the only tool-launch command, but Azure Data Studio is deprecated and no longer the primary tool for SQL Server development.
Solution
Add sqlcmd open vscode and sqlcmd open ssms commands alongside the existing sqlcmd open ads.
Changes
Design Decisions
Testing
Supersedes #685. Fixes #584.