sensor control
(ctx context.Context)
| 301 | |
| 302 | // sensor control <stop-target-app|wait-for-event|change-log-level|...> |
| 303 | func runControlCommand(ctx context.Context) error { |
| 304 | if len(os.Args) < 3 { |
| 305 | return errors.New("missing command") |
| 306 | } |
| 307 | |
| 308 | cmd := control.Command(os.Args[2]) |
| 309 | |
| 310 | switch cmd { |
| 311 | case control.StopTargetAppCommand: |
| 312 | if err := control.ExecuteStopTargetAppCommand(ctx, *commandsFile); err != nil { |
| 313 | return fmt.Errorf("error stopping target app: %w", err) |
| 314 | } |
| 315 | |
| 316 | case control.WaitForEventCommand: |
| 317 | if len(os.Args) < 4 { |
| 318 | return errors.New("missing event name") |
| 319 | } |
| 320 | if err := control.ExecuteWaitEvenCommand(ctx, eventsFilePath(), event.Type(os.Args[3])); err != nil { |
| 321 | return fmt.Errorf("error waiting for sensor event: %w", err) |
| 322 | } |
| 323 | |
| 324 | default: |
| 325 | return fmt.Errorf("unknown command: %s", cmd) |
| 326 | } |
| 327 | |
| 328 | return nil |
| 329 | } |
no test coverage detected