|
4 | 4 | package install |
5 | 5 |
|
6 | 6 | import ( |
7 | | - "encoding/base64" |
8 | | - "encoding/json" |
9 | 7 | "fmt" |
10 | | - "github.com/microsoft/go-sqlcmd/internal/cmdparser/dependency" |
11 | | - "github.com/microsoft/go-sqlcmd/internal/tools" |
12 | | - "github.com/microsoft/go-sqlcmd/pkg/mssqlcontainer/ingest" |
13 | | - "os" |
14 | 8 | "runtime" |
15 | 9 | "strings" |
16 | 10 |
|
17 | 11 | "github.com/microsoft/go-sqlcmd/cmd/modern/root/open" |
18 | | - |
19 | 12 | "github.com/microsoft/go-sqlcmd/cmd/modern/sqlconfig" |
20 | 13 | "github.com/microsoft/go-sqlcmd/internal/cmdparser" |
| 14 | + "github.com/microsoft/go-sqlcmd/internal/cmdparser/dependency" |
21 | 15 | "github.com/microsoft/go-sqlcmd/internal/config" |
22 | 16 | "github.com/microsoft/go-sqlcmd/internal/container" |
23 | 17 | "github.com/microsoft/go-sqlcmd/internal/output" |
24 | 18 | "github.com/microsoft/go-sqlcmd/internal/pal" |
25 | 19 | "github.com/microsoft/go-sqlcmd/internal/secret" |
26 | 20 | "github.com/microsoft/go-sqlcmd/internal/sql" |
| 21 | + "github.com/microsoft/go-sqlcmd/internal/tools" |
| 22 | + "github.com/microsoft/go-sqlcmd/pkg/mssqlcontainer/ingest" |
27 | 23 | "github.com/spf13/viper" |
28 | 24 | ) |
29 | 25 |
|
@@ -104,10 +100,18 @@ func (c *MssqlBase) AddFlags( |
104 | 100 | Usage: "Context name (a default context name will be created if not provided)", |
105 | 101 | }) |
106 | 102 |
|
| 103 | + // BUG(stuartpa): Make this a hidden flag so we don't break existing usage |
107 | 104 | addFlag(cmdparser.FlagOptions{ |
108 | 105 | String: &c.defaultDatabase, |
109 | 106 | Name: "user-database", |
110 | 107 | Shorthand: "u", |
| 108 | + Usage: "[DEPRECATED use --database] Create a user database and set it as the default for login", |
| 109 | + }) |
| 110 | + |
| 111 | + addFlag(cmdparser.FlagOptions{ |
| 112 | + String: &c.defaultDatabase, |
| 113 | + Name: "database", |
| 114 | + Shorthand: "d", |
111 | 115 | Usage: "Create a user database and set it as the default for login", |
112 | 116 | }) |
113 | 117 |
|
@@ -219,25 +223,26 @@ func (c *MssqlBase) AddFlags( |
219 | 223 | Usage: "Port (next available port from 1433 upwards used by default)", |
220 | 224 | }) |
221 | 225 |
|
| 226 | + // BUG(stuartpa): Make this a hidden flag so we don't break existing usage |
222 | 227 | addFlag(cmdparser.FlagOptions{ |
223 | 228 | String: &c.useDatabaseUrl, |
224 | 229 | DefaultString: "", |
225 | 230 | Name: "using", |
226 | | - Usage: "Download and use database from .bak/.bacpac/.mdf/.7z URL", |
| 231 | + Usage: fmt.Sprintf("[DEPRECATED use --use] Download %q and use database", ingest.ValidFileExtensions()), |
227 | 232 | }) |
228 | 233 |
|
229 | 234 | addFlag(cmdparser.FlagOptions{ |
230 | 235 | String: &c.useDatabaseUrl, |
231 | 236 | DefaultString: "", |
232 | 237 | Name: "use", |
233 | | - Usage: "Download and use database from .bak/.bacpac/.mdf/.7z URL", |
| 238 | + Usage: fmt.Sprintf("Download %q and use database", ingest.ValidFileExtensions()), |
234 | 239 | }) |
235 | 240 |
|
236 | 241 | addFlag(cmdparser.FlagOptions{ |
237 | 242 | String: &c.useMechanism, |
238 | 243 | DefaultString: "", |
239 | 244 | Name: "use-mechanism", |
240 | | - Usage: "Mechanism to use to make --use database online (attach, restore, dacfx)", |
| 245 | + Usage: "Mechanism to use to bring database online (attach, restore, dacfx)", |
241 | 246 | }) |
242 | 247 |
|
243 | 248 | addFlag(cmdparser.FlagOptions{ |
@@ -321,7 +326,7 @@ func (c *MssqlBase) createContainer(imageName string, contextName string) { |
321 | 326 | []string{ |
322 | 327 | fmt.Sprintf( |
323 | 328 | "--using must be a path to a file with a %q extension", |
324 | | - strings.Join(useDatabase.ValidFileExtensions(), ", "), |
| 329 | + ingest.ValidFileExtensions(), |
325 | 330 | ), |
326 | 331 | }, |
327 | 332 | "%q is not a valid file extension for --using flag", useDatabase.UserProvidedFileExt()) |
@@ -500,17 +505,6 @@ func (c *MssqlBase) createContainer(imageName string, contextName string) { |
500 | 505 | output.Fatalf(tool.HowToInstall()) |
501 | 506 | } |
502 | 507 |
|
503 | | - if c.openFile != "" { |
504 | | - args = append(args, c.openFile) |
505 | | - |
506 | | - a := os.Args[1:] |
507 | | - data, _ := json.Marshal(&a) |
508 | | - |
509 | | - fmt.Printf("The URL for sharing this `sqlcmd create` is:\n\n") |
510 | | - sEnc := base64.StdEncoding.EncodeToString(data) |
511 | | - fmt.Printf("sqlcmd://%s\n", sEnc) |
512 | | - } |
513 | | - |
514 | 508 | _, err := tool.Run(args) |
515 | 509 | c.CheckErr(err) |
516 | 510 | } |
|
0 commit comments