@@ -250,15 +250,7 @@ func (b *Remote) costEstimate(stopCtx, cancelCtx context.Context, op *backend.Op
250250 return nil
251251 }
252252
253- if b .CLI != nil {
254- b .CLI .Output ("\n ------------------------------------------------------------------------\n " )
255- }
256-
257253 msgPrefix := "Cost estimation"
258- if b .CLI != nil {
259- b .CLI .Output (b .Colorize ().Color (msgPrefix + ":\n " ))
260- }
261-
262254 started := time .Now ()
263255 updated := started
264256 for i := 0 ; ; i ++ {
@@ -284,6 +276,12 @@ func (b *Remote) costEstimate(stopCtx, cancelCtx context.Context, op *backend.Op
284276 }
285277 }
286278
279+ // checking if i == 0 so as to avoid printing this starting horizontal-rule
280+ // every retry, and that it only prints it on the first (i=0) attempt.
281+ if b .CLI != nil && i == 0 {
282+ b .CLI .Output ("\n ------------------------------------------------------------------------\n " )
283+ }
284+
287285 switch ce .Status {
288286 case tfe .CostEstimateFinished :
289287 delta , err := strconv .ParseFloat (ce .DeltaMonthlyCost , 64 )
@@ -299,6 +297,7 @@ func (b *Remote) costEstimate(stopCtx, cancelCtx context.Context, op *backend.Op
299297 deltaRepr := strings .Replace (ce .DeltaMonthlyCost , "-" , "" , 1 )
300298
301299 if b .CLI != nil {
300+ b .CLI .Output (b .Colorize ().Color (msgPrefix + ":\n " ))
302301 b .CLI .Output (b .Colorize ().Color (fmt .Sprintf ("Resources: %d of %d estimated" , ce .MatchedResourcesCount , ce .ResourcesCount )))
303302 b .CLI .Output (b .Colorize ().Color (fmt .Sprintf (" $%s/mo %s$%s" , ce .ProposedMonthlyCost , sign , deltaRepr )))
304303
@@ -320,10 +319,12 @@ func (b *Remote) costEstimate(stopCtx, cancelCtx context.Context, op *backend.Op
320319 elapsed = fmt .Sprintf (
321320 " (%s elapsed)" , current .Sub (started ).Truncate (30 * time .Second ))
322321 }
322+ b .CLI .Output (b .Colorize ().Color (msgPrefix + ":\n " ))
323323 b .CLI .Output (b .Colorize ().Color ("Waiting for cost estimate to complete..." + elapsed + "\n " ))
324324 }
325325 continue
326326 case tfe .CostEstimateSkippedDueToTargeting :
327+ b .CLI .Output (b .Colorize ().Color (msgPrefix + ":\n " ))
327328 b .CLI .Output ("Not available for this plan, because it was created with the -target option." )
328329 b .CLI .Output ("\n ------------------------------------------------------------------------" )
329330 return nil
0 commit comments