Skip to content

Commit 75fc78c

Browse files
committed
Two fixes
1 parent e3e6e71 commit 75fc78c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cmd/modern/root/config/add-context.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ func (c *AddContext) DefineCommand(...cmdparser.CommandOptions) {
2626
Examples: []cmdparser.ExampleOptions{
2727
{
2828
Description: "Add a default context",
29-
Steps: []string{"sqlcmd config add-context --name my-context"}},
29+
Steps: []string{
30+
"sqlcmd config add-endpoint --name localhost-1433",
31+
"sqlcmd config add-context --name my-context --endpoint localhost-1433"}},
3032
},
3133
Run: c.run}
3234

internal/config/context.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ func AddContext(context Context) {
1818
if !EndpointExists(context.Endpoint) {
1919
panic("Endpoint doesn't exist")
2020
}
21+
<<<<<<< Updated upstream
2122
context.Name = FindUniqueContextName(context.Name, *context.User)
23+
=======
24+
username := ""
25+
if context.User != nil && *context.User != "" {
26+
username = *context.User
27+
}
28+
29+
context.Name = FindUniqueContextName(context.Name, username)
30+
>>>>>>> Stashed changes
2231
config.Contexts = append(config.Contexts, context)
2332
Save()
2433
}

0 commit comments

Comments
 (0)