99 "github.com/microsoft/go-sqlcmd/cmd/modern/sqlconfig"
1010 "github.com/microsoft/go-sqlcmd/internal/cmdparser"
1111 "github.com/microsoft/go-sqlcmd/internal/config"
12+ "github.com/microsoft/go-sqlcmd/internal/localizer"
1213)
1314
1415// AddContext implements the `sqlcmd config add-context` command
@@ -23,10 +24,10 @@ type AddContext struct {
2324func (c * AddContext ) DefineCommand (... cmdparser.CommandOptions ) {
2425 options := cmdparser.CommandOptions {
2526 Use : "add-context" ,
26- Short : "Add a context" ,
27+ Short : localizer . Sprintf ( "Add a context" ) ,
2728 Examples : []cmdparser.ExampleOptions {
2829 {
29- Description : "Add a context for a local instance of SQL Server on port 1433 using trusted authentication" ,
30+ Description : localizer . Sprintf ( "Add a context for a local instance of SQL Server on port 1433 using trusted authentication" ) ,
3031 Steps : []string {
3132 "sqlcmd config add-endpoint --name localhost-1433" ,
3233 "sqlcmd config add-context --name mssql --endpoint localhost-1433" }},
@@ -39,17 +40,17 @@ func (c *AddContext) DefineCommand(...cmdparser.CommandOptions) {
3940 String : & c .name ,
4041 Name : "name" ,
4142 DefaultString : "context" ,
42- Usage : "Display name for the context" })
43+ Usage : localizer . Sprintf ( "Display name for the context" ) })
4344
4445 c .AddFlag (cmdparser.FlagOptions {
4546 String : & c .endpointName ,
4647 Name : "endpoint" ,
47- Usage : "Name of endpoint this context will use" })
48+ Usage : localizer . Sprintf ( "Name of endpoint this context will use" ) })
4849
4950 c .AddFlag (cmdparser.FlagOptions {
5051 String : & c .userName ,
5152 Name : "user" ,
52- Usage : "Name of user this context will use" })
53+ Usage : localizer . Sprintf ( "Name of user this context will use" ) })
5354}
5455
5556// run adds a context to the configuration and sets it as the current context. The
@@ -69,27 +70,27 @@ func (c *AddContext) run() {
6970
7071 if c .endpointName == "" || ! config .EndpointExists (c .endpointName ) {
7172 output .FatalfWithHintExamples ([][]string {
72- {"View existing endpoints to choose from" , "sqlcmd config get-endpoints" },
73- {"Add a new local endpoint" , "sqlcmd create" },
74- {"Add an already existing endpoint" , "sqlcmd config add-endpoint --address localhost --port 1433" }},
75- "Endpoint required to add context. Endpoint '%v' does not exist. Use --endpoint flag" , c .endpointName )
73+ {localizer . Sprintf ( "View existing endpoints to choose from" ) , "sqlcmd config get-endpoints" },
74+ {localizer . Sprintf ( "Add a new local endpoint" ) , "sqlcmd create" },
75+ {localizer . Sprintf ( "Add an already existing endpoint" ) , "sqlcmd config add-endpoint --address localhost --port 1433" }},
76+ localizer . Sprintf ( "Endpoint required to add context. Endpoint '%v' does not exist. Use %s flag" , c .endpointName , localizer . EndpointFlag ) )
7677 }
7778
7879 if c .userName != "" {
7980 if ! config .UserNameExists (c .userName ) {
8081 output .FatalfWithHintExamples ([][]string {
81- {"View list of users" , "sqlcmd config get-users" },
82- {"Add the user" , fmt .Sprintf ("sqlcmd config add-user --name %v" , c .userName )},
83- {"Add an endpoint" , "sqlcmd create" }},
84- "User '%v' does not exist" , c .userName )
82+ {localizer . Sprintf ( "View list of users" ) , "sqlcmd config get-users" },
83+ {localizer . Sprintf ( "Add the user" ) , fmt .Sprintf ("sqlcmd config add-user --name %v" , c .userName )},
84+ {localizer . Sprintf ( "Add an endpoint" ) , "sqlcmd create" }},
85+ localizer . Sprintf ( "User '%v' does not exist" , c .userName ) )
8586 }
8687 }
8788
8889 context .Name = config .AddContext (context )
8990 config .SetCurrentContextName (context .Name )
9091 output .InfofWithHintExamples ([][]string {
91- {"Open in Azure Data Studio" , "sqlcmd open ads" },
92- {"To start interactive query session" , "sqlcmd query" },
93- {"To run a query" , "sqlcmd query \" SELECT @@version\" " },
94- }, "Current Context '%v'" , context .Name )
92+ {localizer . Sprintf ( "Open in Azure Data Studio" ) , "sqlcmd open ads" },
93+ {localizer . Sprintf ( "To start interactive query session" ) , "sqlcmd query" },
94+ {localizer . Sprintf ( "To run a query" ) , "sqlcmd query \" SELECT @@version\" " },
95+ }, localizer . Sprintf ( "Current Context '%v'" , context .Name ) )
9596}
0 commit comments