Skip to content

Commit 15ea586

Browse files
Copilotshueybubbles
andcommitted
Fix error messages to use correct flag syntax (-N s instead of -Ys)
Co-authored-by: shueybubbles <[email protected]>
1 parent a618537 commit 15ea586

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ darwin-arm64/sqlcmd
3232
linux-amd64/sqlcmd
3333
linux-arm64/sqlcmd
3434
linux-s390x/sqlcmd
35+
36+
# Build artifacts in root
37+
/sqlcmd
38+
/sqlcmd_binary

cmd/sqlcmd/sqlcmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (a *SQLCmdArguments) Validate(c *cobra.Command) (err error) {
159159
case a.QueryTimeout < 0 || a.QueryTimeout > 65534:
160160
err = rangeParameterError("-t", fmt.Sprint(a.QueryTimeout), 0, 65534, true)
161161
case a.ServerCertificate != "" && a.EncryptConnection != "s" && a.EncryptConnection != "strict":
162-
err = localizer.Errorf("The -J parameter can only be used with strict encryption mode (-Ys or -N strict).")
162+
err = localizer.Errorf("The -J parameter can only be used with strict encryption mode (-N s or -N strict).")
163163
}
164164
}
165165
if err != nil {
@@ -432,7 +432,7 @@ func setFlags(rootCmd *cobra.Command, args *SQLCmdArguments) {
432432
rootCmd.Flags().StringVarP(&args.ApplicationIntent, applicationIntent, "K", "default", localizer.Sprintf("Declares the application workload type when connecting to a server. The only currently supported value is ReadOnly. If %s is not specified, the sqlcmd utility will not support connectivity to a secondary replica in an Always On availability group", localizer.ApplicationIntentFlagShort))
433433
rootCmd.Flags().StringVarP(&args.EncryptConnection, encryptConnection, "N", "default", localizer.Sprintf("This switch is used by the client to request an encrypted connection"))
434434
rootCmd.Flags().StringVarP(&args.HostNameInCertificate, "host-name-in-certificate", "F", "", localizer.Sprintf("Specifies the host name in the server certificate."))
435-
rootCmd.Flags().StringVarP(&args.ServerCertificate, "server-certificate", "J", "", localizer.Sprintf("Specifies the path to a server certificate file (PEM, DER, or CER) to match against the server's TLS certificate. Used with strict encryption mode (-Ys) for certificate pinning instead of standard certificate validation."))
435+
rootCmd.Flags().StringVarP(&args.ServerCertificate, "server-certificate", "J", "", localizer.Sprintf("Specifies the path to a server certificate file (PEM, DER, or CER) to match against the server's TLS certificate. Used with strict encryption mode (-N s or -N strict) for certificate pinning instead of standard certificate validation."))
436436
// Can't use NoOptDefVal until this fix: https://github.com/spf13/cobra/issues/866
437437
//rootCmd.Flags().Lookup(encryptConnection).NoOptDefVal = "true"
438438
rootCmd.Flags().BoolVarP(&args.Vertical, "vertical", "", false, localizer.Sprintf("Prints the output in vertical format. This option sets the sqlcmd scripting variable %s to '%s'. The default is false", sqlcmd.SQLCMDFORMAT, "vert"))

cmd/sqlcmd/sqlcmd_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ func TestInvalidCommandLine(t *testing.T) {
168168
{[]string{"-;"}, "';': Unknown Option. Enter '-?' for help."},
169169
{[]string{"-t", "-2"}, "'-t -2': value must be greater than or equal to 0 and less than or equal to 65534."},
170170
{[]string{"-N", "invalid"}, "'-N invalid': Unexpected argument. Argument value has to be one of [m[andatory] yes 1 t[rue] disable o[ptional] no 0 f[alse] s[trict]]."},
171-
{[]string{"-J", "/path/to/cert.pem"}, "The -J parameter can only be used with strict encryption mode (-Ys or -N strict)."},
172-
{[]string{"-N", "m", "-J", "/path/to/cert.pem"}, "The -J parameter can only be used with strict encryption mode (-Ys or -N strict)."},
173-
{[]string{"-N", "optional", "-J", "/path/to/cert.pem"}, "The -J parameter can only be used with strict encryption mode (-Ys or -N strict)."},
171+
{[]string{"-J", "/path/to/cert.pem"}, "The -J parameter can only be used with strict encryption mode (-N s or -N strict)."},
172+
{[]string{"-N", "m", "-J", "/path/to/cert.pem"}, "The -J parameter can only be used with strict encryption mode (-N s or -N strict)."},
173+
{[]string{"-N", "optional", "-J", "/path/to/cert.pem"}, "The -J parameter can only be used with strict encryption mode (-N s or -N strict)."},
174174
}
175175

176176
for _, test := range commands {

0 commit comments

Comments
 (0)