()
| 9 | ) |
| 10 | |
| 11 | func NewCmds() []*cobra.Command { |
| 12 | cmd := &cobra.Command{ |
| 13 | Use: "watch [task-id]", |
| 14 | Short: "Wait for an async task to complete", |
| 15 | Long: heredoc.Doc(` |
| 16 | This command waits for a specific async backend operation |
| 17 | to complete. Such as deleting a user or exporting a channel. |
| 18 | `), |
| 19 | Example: heredoc.Doc(` |
| 20 | # Delete user and watching it complete |
| 21 | $ stream-cli chat delete-users "my-user-1" |
| 22 | > Successfully initiated user deletion. Task id: 7586fa0d-dc8d-4f6f-be2d-f952d0e26167 |
| 23 | |
| 24 | # Waiting for the task to complete |
| 25 | $ stream-cli chat watch 7586fa0d-dc8d-4f6f-be2d-f952d0e26167 |
| 26 | |
| 27 | # Providing a timeout of 80 seconds |
| 28 | $ stream-cli chat watch 7586fa0d-dc8d-4f6f-be2d-f952d0e26167 --timeout 80 |
| 29 | `), |
| 30 | Args: cobra.ExactArgs(1), |
| 31 | RunE: func(cmd *cobra.Command, args []string) error { |
| 32 | taskID := args[0] |
| 33 | timeout, _ := cmd.Flags().GetInt("timeout") |
| 34 | c, err := config.GetConfig(cmd).GetClient(cmd) |
| 35 | if err != nil { |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | return utils.WaitForAsyncCompletion(cmd, c, taskID, timeout) |
| 40 | }, |
| 41 | } |
| 42 | |
| 43 | cmd.Flags().IntP("timeout", "t", 30, "[optional] Timeout in seconds. Default is 30") |
| 44 | |
| 45 | return []*cobra.Command{cmd} |
| 46 | } |
no test coverage detected