Skip to content

Commit 4d68aae

Browse files
author
Luca Bianconi
committed
refactor: cleanup
1 parent 647d629 commit 4d68aae

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: internal/cli/compile/compile.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,16 @@ const (
5252
showPropertiesModeValue
5353
)
5454

55-
func getShowPropertiesMode(showProperties string) showPropertiesMode {
56-
if showProperties == "" {
57-
// default with no flag
58-
return showPropertiesModeDisabled
59-
}
55+
func parseShowPropertiesMode(showProperties string) (showPropertiesMode, error) {
6056
val, ok := map[string]showPropertiesMode{
6157
"disabled": showPropertiesModeDisabled,
6258
"pattern": showPropertiesModePattern,
6359
"value": showPropertiesModeValue,
6460
}[showProperties]
6561
if !ok {
66-
return showPropertiesModePattern
62+
return showPropertiesModeDisabled, fmt.Errorf(tr("invalid option '%s'.", showProperties))
6763
}
68-
return val
64+
return val, nil
6965
}
7066

7167
var (
@@ -219,7 +215,11 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
219215
overrides = o.Overrides
220216
}
221217

222-
showPropertiesM := getShowPropertiesMode(showProperties)
218+
showPropertiesM, err := parseShowPropertiesMode(showProperties)
219+
if err != nil {
220+
feedback.Fatal(tr("Error parsing --show-properties flag: %v", err), feedback.ErrGeneric)
221+
}
222+
223223
var stdOut, stdErr io.Writer
224224
var stdIORes func() *feedback.OutputStreamsResult
225225
if showPropertiesM != showPropertiesModeDisabled {

0 commit comments

Comments
 (0)