Skip to content

Commit dfa27e0

Browse files
authored
Stub -M and fix !! (#152)
* stub -M * support no space after !! * add more flag help
1 parent cb5dd57 commit dfa27e0

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

cmd/sqlcmd/main.go

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ type SQLCmdArguments struct {
5858
ColumnSeparator string `short:"s" help:"Specifies the column separator character. Sets the SQLCMDCOLSEP variable."`
5959
ScreenWidth *int `short:"w" help:"Specifies the screen width for output. Sets the SQLCMDCOLWIDTH variable."`
6060
TrimSpaces bool `short:"W" help:"Remove trailing spaces from a column."`
61+
MultiSubnetFailover bool `short:"M" help:"Provided for backward compatibility. Sqlcmd always optimizes detection of the active replica of a SQL Failover Cluster."`
62+
Password string `short:"P" help:"Obsolete. The initial passwords must be set using the SQLCMDPASSWORD environment variable or entered at the password prompt."`
6163
// Keep Help at the end of the list
6264
Help bool `short:"?" help:"Show syntax summary."`
6365
}
@@ -74,6 +76,9 @@ func (a *SQLCmdArguments) Validate() error {
7476
if a.ScreenWidth != nil && (*a.ScreenWidth < 9 || *a.ScreenWidth > 65535) {
7577
return fmt.Errorf(`'-w %d': value must be greater than 8 and less than 65536.`, *a.ScreenWidth)
7678
}
79+
if a.Password != "" {
80+
return fmt.Errorf(`'-P' is obsolete. The initial passwords must be set using the SQLCMDPASSWORD environment variable or entered at the password prompt.`)
81+
}
7782
return nil
7883
}
7984

pkg/sqlcmd/commands.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func newCommands() Commands {
9191
name: "CONNECT",
9292
},
9393
"EXEC": {
94-
regex: regexp.MustCompile(`(?im)^[ \t]*?:?!!(?:[ \t]+(.*$)|$)`),
94+
regex: regexp.MustCompile(`(?im)^[ \t]*?:?!!(.*$)`),
9595
action: execCommand,
9696
name: "EXEC",
9797
isSystem: true,

pkg/sqlcmd/commands_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ func TestCommandParsing(t *testing.T) {
4646
{`EXIT `, "EXIT", []string{""}},
4747
{`:Connect someserver -U someuser`, "CONNECT", []string{"someserver -U someuser"}},
4848
{`:r c:\$(var)\file.sql`, "READFILE", []string{`c:\$(var)\file.sql`}},
49-
{`:!! notepad`, "EXEC", []string{"notepad"}},
50-
{` !! dir c:\`, "EXEC", []string{`dir c:\`}},
49+
{`:!! notepad`, "EXEC", []string{" notepad"}},
50+
{`:!!notepad`, "EXEC", []string{"notepad"}},
51+
{` !! dir c:\`, "EXEC", []string{` dir c:\`}},
52+
{`!!dir c:\`, "EXEC", []string{`dir c:\`}},
5153
}
5254

5355
for _, test := range commands {

0 commit comments

Comments
 (0)