Skip to content

Commit c0ab2d4

Browse files
committed
small updates
1 parent 652751b commit c0ab2d4

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

cmd/cmd_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ func showUsageExample(cmd *cobra.Command, details string) {
670670
suggestion = exampleContent.Suggestion
671671
details += "\n## Usage Examples:\n" + exampleContent.Content
672672
}
673-
u.PrintErrorMarkdownAndExit("Incorrect Usage", fmt.Errorf(details), suggestion)
673+
u.PrintInvalidUsageErrorAndExit(errors.New(details))
674674
}
675675

676676
// Contains checks if a slice of strings contains an exact match for the target string.

cmd/list_components.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var listComponentsCmd = &cobra.Command{
2929

3030
stackFlag, err := flags.GetString("stack")
3131
if err != nil {
32-
u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `stack` flag: `%v`", err), "")
32+
u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `stack` flag: `%v`", err))
3333
return
3434
}
3535

cmd/list_workflows.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ var listWorkflowsCmd = &cobra.Command{
2626

2727
fileFlag, err := flags.GetString("file")
2828
if err != nil {
29-
u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `file` flag: %v", err), "")
29+
u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `file` flag: %v", err))
3030
return
3131
}
3232

3333
formatFlag, err := flags.GetString("format")
3434
if err != nil {
35-
u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `format` flag: %v", err), "")
35+
u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `format` flag: %v", err))
3636
return
3737
}
3838

3939
delimiterFlag, err := flags.GetString("delimiter")
4040
if err != nil {
41-
u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `delimiter` flag: %v", err), "")
41+
u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `delimiter` flag: %v", err))
4242
return
4343
}
4444

pkg/utils/markdown_utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
"github.com/cloudposse/atmos/pkg/schema"
1111
"github.com/cloudposse/atmos/pkg/ui/markdown"
12+
"golang.org/x/text/cases"
13+
"golang.org/x/text/language"
1214

1315
l "github.com/charmbracelet/log"
1416
)
@@ -27,6 +29,7 @@ func PrintErrorMarkdown(title string, err error, suggestion string) {
2729
if title == "" {
2830
title = "Error"
2931
}
32+
title = cases.Title(language.English).String(title)
3033
errorMarkdown, renderErr := render.RenderError(title, err.Error(), suggestion)
3134
if renderErr != nil {
3235
LogError(err)
@@ -66,6 +69,10 @@ func PrintErrorMarkdownAndExit(title string, err error, suggestion string) {
6669
os.Exit(1)
6770
}
6871

72+
func PrintInvalidUsageErrorAndExit(err error) {
73+
PrintErrorMarkdownAndExit("Invalid Usage", err, "")
74+
}
75+
6976
func PrintfMarkdown(format string, a ...interface{}) {
7077
if render == nil {
7178
_, err := os.Stdout.WriteString(fmt.Sprintf(format, a...))

0 commit comments

Comments
 (0)