Skip to content

Commit 173880f

Browse files
refactor: drop restate-the-code comments from open/clipboard files
1 parent 2b50034 commit 173880f

7 files changed

Lines changed: 6 additions & 32 deletions

File tree

cmd/modern/root/open/clipboard.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,20 @@ import (
1111
"github.com/microsoft/go-sqlcmd/internal/pal"
1212
)
1313

14-
// copyPasswordToClipboard copies the password for the current context to the clipboard
15-
// if the user is using SQL authentication. Returns true if a password was copied.
14+
// copyPasswordToClipboard copies the current context's password to the clipboard for SQL auth.
15+
// Returns true when a password was actually copied.
1616
func copyPasswordToClipboard(user *sqlconfig.User, out *output.Output) bool {
1717
if out == nil || user == nil || user.AuthenticationType != "basic" || user.BasicAuth == nil {
1818
return false
1919
}
2020

21-
// Get the decrypted password from the current context
2221
_, _, password := config.GetCurrentContextInfo()
23-
2422
if password == "" {
2523
return false
2624
}
2725

28-
err := pal.CopyToClipboard(password)
29-
if err != nil {
30-
// Don't fail the command if clipboard copy fails, just warn the user
26+
if err := pal.CopyToClipboard(password); err != nil {
27+
// Don't fail the launch over a clipboard hiccup; warn and continue.
3128
out.Warn(localizer.Sprintf("Could not copy password to clipboard: %s", err.Error()))
3229
return false
3330
}

cmd/modern/root/open/ssms_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/microsoft/go-sqlcmd/internal/localizer"
88
)
99

10-
// On Windows, display info before launching
1110
func (c *SSMS) displayPreLaunchInfo() {
1211
output := c.Output()
1312
output.Info(localizer.Sprintf("Launching SQL Server Management Studio..."))

cmd/modern/root/open/vscode.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ func (c *VSCode) DefineCommand(...cmdparser.CommandOptions) {
5555
})
5656
}
5757

58-
// Launch VS Code and configure connection profile for the current context.
59-
// The connection profile will be added to VS Code's user settings to work
60-
// with the MSSQL extension.
6158
func (c *VSCode) run() {
6259
if config.CurrentContextName() == "" {
6360
c.Output().FatalWithHintExamples([][]string{
@@ -156,7 +153,6 @@ func (c *VSCode) launchVSCode(t tool.Tool, endpoint sqlconfig.Endpoint, user *sq
156153
c.CheckErr(err)
157154
}
158155

159-
// createConnectionProfile creates or updates a connection profile in VS Code's user settings
160156
func (c *VSCode) createConnectionProfile(build string, endpoint sqlconfig.Endpoint, user *sqlconfig.User, isLocalConnection bool) {
161157
output := c.Output()
162158

internal/pal/clipboard.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
package pal
55

6-
// CopyToClipboard copies the given text to the system clipboard.
7-
// Returns an error if the clipboard operation fails.
6+
// CopyToClipboard copies text to the system clipboard.
87
func CopyToClipboard(text string) error {
98
return copyToClipboard(text)
109
}

internal/pal/clipboard_linux.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,31 @@ import (
1010
)
1111

1212
func copyToClipboard(text string) error {
13-
// Try xclip first, then xsel, then wl-copy as fallbacks.
14-
// These are common clipboard utilities on Linux.
15-
1613
var attempts []string
17-
18-
// Helper to try a single command and record any errors.
1914
tryCmd := func(name string, args ...string) bool {
2015
if _, err := exec.LookPath(name); err != nil {
2116
attempts = append(attempts, fmt.Sprintf("%s not found", name))
2217
return false
2318
}
24-
2519
cmd := exec.Command(name, args...)
2620
cmd.Stdin = strings.NewReader(text)
2721
if err := cmd.Run(); err != nil {
2822
attempts = append(attempts, fmt.Sprintf("%s failed: %v", name, err))
2923
return false
3024
}
31-
3225
return true
3326
}
3427

35-
// Try xclip
3628
if tryCmd("xclip", "-selection", "clipboard") {
3729
return nil
3830
}
39-
40-
// Try xsel as fallback
4131
if tryCmd("xsel", "--clipboard", "--input") {
4232
return nil
4333
}
44-
45-
// Try wl-copy for Wayland
4634
if tryCmd("wl-copy") {
4735
return nil
4836
}
4937

50-
// All attempts failed - return combined error message. Plain fmt.Errorf
51-
// because gotext only scans cmd/modern, cmd/sqlcmd, and pkg/sqlcmd; calling
52-
// localizer.Errorf from internal/pal would never make it into the catalog.
38+
// gotext only scans cmd/modern, cmd/sqlcmd, and pkg/sqlcmd, so this stays plain fmt.Errorf.
5339
return fmt.Errorf("failed to copy to clipboard; tried xclip, xsel, wl-copy: %s", strings.Join(attempts, "; "))
5440
}

internal/pal/clipboard_windows.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"strings"
1111
)
1212

13-
// copyToClipboard copies text to the Windows clipboard using the built-in clip.exe command.
14-
// This is simpler and safer than using Win32 API calls directly.
1513
func copyToClipboard(text string) error {
1614
cmd := exec.Command(clipExePath())
1715
cmd.Stdin = strings.NewReader(text)

internal/tools/tool/tool.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func (t *tool) IsInstalled() bool {
4848
}
4949

5050
t.installed = new(bool)
51-
// Handle case where tool wasn't found during Init (exeName is empty)
5251
if t.exeName != "" && file.Exists(t.exeName) {
5352
*t.installed = true
5453
} else {

0 commit comments

Comments
 (0)