File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package config
55
66import (
77 "fmt"
8+
89 "github.com/microsoft/go-sqlcmd/cmd/modern/sqlconfig"
910 "github.com/microsoft/go-sqlcmd/internal/cmdparser"
1011 "github.com/microsoft/go-sqlcmd/internal/config"
@@ -82,7 +83,7 @@ func (c *AddContext) run() {
8283 }
8384 }
8485
85- config .AddContext (context )
86+ context . Name = config .AddContext (context )
8687 config .SetCurrentContextName (context .Name )
8788 output .InfofWithHintExamples ([][]string {
8889 {"Open in Azure Data Studio" , "sqlcmd open ads" },
Original file line number Diff line number Diff line change @@ -6,15 +6,17 @@ package config
66import (
77 "errors"
88 "fmt"
9- . "github.com/microsoft/go-sqlcmd/cmd/modern/sqlconfig"
109 "strconv"
10+
11+ . "github.com/microsoft/go-sqlcmd/cmd/modern/sqlconfig"
1112)
1213
13- // AddContext adds the context to the sqlconfig file.
14+ // AddContext adds the context to the sqlconfig file, and returns the context
15+ // name, which maybe uniquified, if the passed in name already exists.
1416//
1517// Before calling this method, verify the Endpoint exists and give the user
1618// a descriptive error, (this function will panic, which should never be hit)
17- func AddContext (context Context ) {
19+ func AddContext (context Context ) string {
1820 if ! EndpointExists (context .Endpoint ) {
1921 panic ("Endpoint doesn't exist" )
2022 }
@@ -25,6 +27,8 @@ func AddContext(context Context) {
2527 context .Name = FindUniqueContextName (context .Name , username )
2628 config .Contexts = append (config .Contexts , context )
2729 Save ()
30+
31+ return context .Name
2832}
2933
3034// CurrentContextName returns the name of the current context in the configuration.
You can’t perform that action at this time.
0 commit comments