(operation parser.Operation)
| 275 | } |
| 276 | |
| 277 | func (b CommandBuilder) createOperationCommand(operation parser.Operation) *CommandDefinition { |
| 278 | parameters := operation.Parameters |
| 279 | b.sortParameters(parameters) |
| 280 | |
| 281 | flags := NewFlagBuilder(). |
| 282 | AddFlags(b.createFlags(parameters)). |
| 283 | AddDefaultFlags(true). |
| 284 | AddHelpFlag(). |
| 285 | Build() |
| 286 | |
| 287 | return NewCommand(operation.Name, operation.Summary, operation.Description). |
| 288 | WithFlags(flags). |
| 289 | WithHelpTemplate(OperationCommandHelpTemplate). |
| 290 | WithHidden(operation.Hidden). |
| 291 | WithAction(func(context *CommandExecContext) error { |
| 292 | profileName := context.String(FlagNameProfile) |
| 293 | config := b.ConfigProvider.Config(profileName) |
| 294 | if config == nil { |
| 295 | return fmt.Errorf("Could not find profile '%s'", profileName) |
| 296 | } |
| 297 | outputFormat, err := b.outputFormat(*config, context) |
| 298 | if err != nil { |
| 299 | return err |
| 300 | } |
| 301 | query := context.String(FlagNameQuery) |
| 302 | wait := context.String(FlagNameWait) |
| 303 | waitTimeout := context.Int(FlagNameWaitTimeout) |
| 304 | |
| 305 | baseUri, err := b.createBaseUri(operation, *config, context) |
| 306 | if err != nil { |
| 307 | return err |
| 308 | } |
| 309 | |
| 310 | input := b.fileInput(context, operation.Parameters) |
| 311 | if input == nil { |
| 312 | err = b.validateArguments(context, operation.Parameters, *config) |
| 313 | if err != nil { |
| 314 | return err |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | parameters, err := b.createExecutionParameters(context, config, operation) |
| 319 | if err != nil { |
| 320 | return err |
| 321 | } |
| 322 | |
| 323 | organization := context.String(FlagNameOrganization) |
| 324 | if organization == "" { |
| 325 | organization = config.Organization |
| 326 | } |
| 327 | tenant := context.String(FlagNameTenant) |
| 328 | if tenant == "" { |
| 329 | tenant = config.Tenant |
| 330 | } |
| 331 | insecure := context.Bool(FlagNameInsecure) || config.Insecure |
| 332 | timeout := time.Duration(context.Int(FlagNameCallTimeout)) * time.Second |
| 333 | if timeout < 0 { |
| 334 | return fmt.Errorf("Invalid value for '%s'", FlagNameCallTimeout) |
no test coverage detected