(opts *MoveOptions)
| 82 | } |
| 83 | |
| 84 | func runMoveCmd(opts *MoveOptions) error { |
| 85 | client, err := opts.SearchClient() |
| 86 | if err != nil { |
| 87 | return err |
| 88 | } |
| 89 | |
| 90 | cs := opts.IO.ColorScheme() |
| 91 | message := fmt.Sprintf( |
| 92 | "Are you sure you want to move %s to %s?", |
| 93 | cs.Bold(opts.SourceIndex), |
| 94 | cs.Bold(opts.DestinationIndex), |
| 95 | ) |
| 96 | |
| 97 | if opts.DoConfirm { |
| 98 | var confirmed bool |
| 99 | p := &survey.Confirm{ |
| 100 | Message: message, |
| 101 | Default: false, |
| 102 | } |
| 103 | err = prompt.SurveyAskOne(p, &confirmed) |
| 104 | if err != nil { |
| 105 | return fmt.Errorf("failed to prompt: %w", err) |
| 106 | } |
| 107 | if !confirmed { |
| 108 | return nil |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | opts.IO.StartProgressIndicatorWithLabel( |
| 113 | fmt.Sprintf("Moving %s to %s", cs.Bold(opts.SourceIndex), cs.Bold(opts.DestinationIndex)), |
| 114 | ) |
| 115 | res, err := client.OperationIndex( |
| 116 | client.NewApiOperationIndexRequest( |
| 117 | opts.SourceIndex, |
| 118 | search.NewEmptyOperationIndexParams(). |
| 119 | SetDestination(opts.DestinationIndex). |
| 120 | SetOperation(search.OPERATION_TYPE_MOVE), |
| 121 | ), |
| 122 | ) |
| 123 | if err != nil { |
| 124 | opts.IO.StopProgressIndicator() |
| 125 | return err |
| 126 | } |
| 127 | |
| 128 | if opts.Wait { |
| 129 | opts.IO.UpdateProgressIndicatorLabel("Waiting for the task to complete") |
| 130 | _, err := client.WaitForTask(opts.DestinationIndex, res.TaskID) |
| 131 | if err != nil { |
| 132 | opts.IO.StopProgressIndicator() |
| 133 | return err |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | opts.IO.StopProgressIndicator() |
| 138 | |
| 139 | if opts.IO.IsStdoutTTY() { |
| 140 | fmt.Fprintf( |
| 141 | opts.IO.Out, |
no test coverage detected