parseSharedQueryOpts reads the process environment variables and CLI flags to populate a clientConfig instance
(cmd *cobra.Command, _ []string)
| 318 | // parseSharedQueryOpts reads the process environment variables and CLI flags to populate a clientConfig |
| 319 | // instance |
| 320 | func parseSharedQueryOpts(cmd *cobra.Command, _ []string) (clientConfig, error) { |
| 321 | // parse parameters and setup options |
| 322 | var ( |
| 323 | opts []clientOption |
| 324 | conf clientConfig |
| 325 | ) |
| 326 | opts = append(opts, readClientConfigEnv()...) |
| 327 | opts = append(opts, readClientConfigFlags(cmd.Flags())...) |
| 328 | for _, fn := range opts { |
| 329 | if err := fn(&conf); err != nil { |
| 330 | return clientConfig{}, fmt.Errorf("could not apply client config option: %w", err) |
| 331 | } |
| 332 | } |
| 333 | // validate config |
| 334 | if conf.serverAddr == "" { |
| 335 | return clientConfig{}, fmt.Errorf("the Perseus server address must be specified") |
| 336 | } |
| 337 | |
| 338 | return conf, nil |
| 339 | } |
| 340 | |
| 341 | // lookupLatestModuleVersion invokes the Perseus API to retrieve the highest known semantic version for |
| 342 | // the specified module. |
no test coverage detected