initCmdExec(&app.Commands)
initCmdMisc(&app.Commands)
+ // Add --config option to all commands to support --config option either before or after command verb
+ // IOW support following both syntaxes:
+ // xds-cli exec --config myprj.conf ...
+ // xds-cli --config myprj.conf exec ...
+ for i, cmd := range app.Commands {
+ if len(cmd.Flags) > 0 {
+ app.Commands[i].Flags = append(cmd.Flags, cli.StringFlag{Hidden: true, Name: "config, c"})
+ }
+ for j, subCmd := range cmd.Subcommands {
+ app.Commands[i].Subcommands[j].Flags = append(subCmd.Flags, cli.StringFlag{Hidden: true, Name: "config, c"})
+ }
+ }
+
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
return cli.NewExitError("ERROR while getting XDS config: "+err.Error(), 1)
}
svrCfg := xdsConf.Servers[XdsServerIndexGet()]
- if serverURL != "" && (svrCfg.URL != serverURL || !svrCfg.Connected) {
- svrCfg.URL = serverURL
+ if (serverURL != "" && svrCfg.URL != serverURL) || !svrCfg.Connected {
+ if serverURL != "" {
+ svrCfg.URL = serverURL
+ }
svrCfg.ConnRetry = 10
if err := XdsConfigSet(xdsConf); err != nil {
return cli.NewExitError("ERROR while updating XDS server URL: "+err.Error(), 1)