Skip to content

Commit 39c085c

Browse files
committed
fix(diff,deploy): highlight stack names and contexts in output messages
Add highlighting to stack names and contexts in all user-facing output statements for better visual distinction. Changes: - Add Highlight() helper function to diff package (currently cyan) - Update diff command output statements to highlight stack name and context - Update deploy command output statements (success, cancellation, no changes) - Highlight context names in 'No stacks found' messages The generic function name allows easy color changes in the future by modifying only the Highlight() implementation. Affected messages: - 'Changes detected for stack X in context Y' - 'No changes detected for stack X in context Y' - 'Successfully deployed stack X in context Y' - 'Stack X create/update completed successfully' - 'Stack creation/deployment cancelled for X' - 'No infrastructure changes for stack X' - 'No stacks found in context X'
1 parent 62be817 commit 39c085c

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

cmd/diff.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ func diffSingleStack(ctx context.Context, stackName, contextName, configFile str
9999
// Set exit code based on whether changes were found
100100
if result.HasChanges() {
101101
// Exit with code 1 if changes detected (similar to git diff)
102-
fmt.Printf("\nChanges detected for stack %s in context %s\n", stackName, contextName)
102+
fmt.Printf("\nChanges detected for stack %s in context %s\n",
103+
diff.Highlight(stackName), diff.Highlight(contextName))
103104
} else {
104-
fmt.Printf("\nNo changes detected for stack %s in context %s\n", stackName, contextName)
105+
fmt.Printf("\nNo changes detected for stack %s in context %s\n",
106+
diff.Highlight(stackName), diff.Highlight(contextName))
105107
}
106108

107109
return nil

internal/aws/cloudformation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ func isChangeSetNoChangesMessage(statusReason string) bool {
814814
"no updates are to be performed",
815815
"no updates to be performed",
816816
}
817-
817+
818818
lowerReason := strings.ToLower(statusReason)
819819
for _, phrase := range noChangePhrases {
820820
if strings.Contains(lowerReason, phrase) {

internal/deploy/deployer.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (d *StackDeployer) deployNewStack(ctx context.Context, stack *model.Stack,
128128
return fmt.Errorf("failed to get user confirmation: %w", err)
129129
}
130130
if !confirmed {
131-
fmt.Printf("\nStack creation cancelled for %s\n", stack.Name)
131+
fmt.Printf("\nStack creation cancelled for %s\n", diff.Highlight(stack.Name))
132132
return CancellationError{StackName: stack.Name}
133133
}
134134

@@ -175,7 +175,7 @@ func (d *StackDeployer) deployNewStack(ctx context.Context, stack *model.Stack,
175175
return fmt.Errorf("failed to create stack: %w", err)
176176
}
177177

178-
fmt.Printf("Stack %s create completed successfully\n", stack.Name)
178+
fmt.Printf("Stack %s create completed successfully\n", diff.Highlight(stack.Name))
179179
return nil
180180
}
181181

@@ -202,15 +202,15 @@ func (d *StackDeployer) deployWithChangeSet(ctx context.Context, stack *model.St
202202
var noChangesErr aws.NoChangesError
203203
if errors.As(diffResult.ChangeSetError, &noChangesErr) {
204204
// Treat metadata-only changes the same as no changes - no deployment needed
205-
fmt.Printf("No infrastructure changes for stack %s (metadata-only changes detected)\n", stack.Name)
205+
fmt.Printf("No infrastructure changes for stack %s (metadata-only changes detected)\n", diff.Highlight(stack.Name))
206206
return NoChangesError{StackName: stack.Name}
207207
}
208208
return fmt.Errorf("cannot deploy: changeset generation failed: %w", diffResult.ChangeSetError)
209209
}
210210

211211
// Check for changes
212212
if !diffResult.HasChanges() {
213-
fmt.Printf("No changes detected for stack %s\n", stack.Name)
213+
fmt.Printf("No changes detected for stack %s\n", diff.Highlight(stack.Name))
214214
return NoChangesError{StackName: stack.Name}
215215
}
216216

@@ -229,7 +229,7 @@ func (d *StackDeployer) deployWithChangeSet(ctx context.Context, stack *model.St
229229
if diffResult.ChangeSet != nil {
230230
_ = cfnOps.DeleteChangeSet(ctx, diffResult.ChangeSet.ChangeSetID)
231231
}
232-
fmt.Printf("\nDeployment cancelled for stack %s\n", stack.Name)
232+
fmt.Printf("\nDeployment cancelled for stack %s\n", diff.Highlight(stack.Name))
233233
return CancellationError{StackName: stack.Name}
234234
}
235235

@@ -272,7 +272,7 @@ func (d *StackDeployer) deployWithChangeSet(ctx context.Context, stack *model.St
272272
// Clean up changeset after successful deployment
273273
_ = cfnOps.DeleteChangeSet(ctx, changeSetInfo.ChangeSetID)
274274

275-
fmt.Printf("Stack %s update completed successfully\n", stack.Name)
275+
fmt.Printf("Stack %s update completed successfully\n", diff.Highlight(stack.Name))
276276
return nil
277277
}
278278

@@ -332,7 +332,7 @@ func (d *StackDeployer) deployStackWithFeedback(ctx context.Context, stack *mode
332332
return fmt.Errorf("error deploying stack %s: %w", stack.Name, err)
333333
}
334334

335-
fmt.Printf("Successfully deployed stack %s in context %s\n", stack.Name, contextName)
335+
fmt.Printf("Successfully deployed stack %s in context %s\n", diff.Highlight(stack.Name), diff.Highlight(contextName))
336336
return nil
337337
}
338338

@@ -355,7 +355,7 @@ func (d *StackDeployer) DeployAllStacks(ctx context.Context, contextName string)
355355
return fmt.Errorf("failed to get stacks for context %s: %w", contextName, err)
356356
}
357357
if len(stackNames) == 0 {
358-
fmt.Printf("No stacks found in context %s\n", contextName)
358+
fmt.Printf("No stacks found in context %s\n", diff.Highlight(contextName))
359359
return nil
360360
}
361361

internal/diff/styles.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,11 @@ func ShouldUseColour() bool {
341341
// Check if it's a character device (terminal)
342342
return (fileInfo.Mode() & os.ModeCharDevice) != 0
343343
}
344+
345+
// Highlight returns the text highlighted in the accent color if colours are enabled
346+
func Highlight(text string) string {
347+
if !ShouldUseColour() {
348+
return text
349+
}
350+
return lipgloss.NewStyle().Foreground(lipgloss.Color("14")).Render(text)
351+
}

0 commit comments

Comments
 (0)