Skip to content

Commit 0862c54

Browse files
committed
Use CLI flag values for string representations of "enum" values
I think this will make the output the easiest for the user to understand, and not require additional documentation beyond what is required to explain the CLI.
1 parent b67f86c commit 0862c54

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

configuration/checkmode/checkmode.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const (
3232
Strict Type = iota // strict
3333
Specification // specification
3434
Permissive // permissive
35-
LibraryManagerSubmission // --library-manager=submit
36-
LibraryManagerIndexed // --library-manager=update
35+
LibraryManagerSubmission // submit
36+
LibraryManagerIndexed // update
3737
Official // ARDUINO_CHECK_OFFICIAL
3838
Default // default
3939
)
@@ -54,11 +54,11 @@ var Types = map[Type]struct{}{
5454
// ComplianceModeFromString parses the --compliance flag value and returns the corresponding check mode settings.
5555
func ComplianceModeFromString(complianceModeString string) (bool, bool, bool, error) {
5656
switch strings.ToLower(complianceModeString) {
57-
case "strict":
57+
case Strict.String():
5858
return true, false, false, nil
59-
case "specification":
59+
case Specification.String():
6060
return false, true, false, nil
61-
case "permissive":
61+
case Permissive.String():
6262
return false, false, true, nil
6363
default:
6464
return false, false, false, fmt.Errorf("No matching compliance mode for string %s", complianceModeString)
@@ -68,9 +68,9 @@ func ComplianceModeFromString(complianceModeString string) (bool, bool, bool, er
6868
// LibraryManagerModeFromString parses the --library-manager flag value and returns the corresponding check mode settings.
6969
func LibraryManagerModeFromString(libraryManagerModeString string) (bool, bool, error) {
7070
switch strings.ToLower(libraryManagerModeString) {
71-
case "submit":
71+
case LibraryManagerSubmission.String():
7272
return true, false, nil
73-
case "update":
73+
case LibraryManagerIndexed.String():
7474
return false, true, nil
7575
case "false":
7676
return false, false, nil

configuration/checkmode/type_string.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

project/projecttype/projecttype.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ type Type int
2828
const (
2929
Sketch Type = iota // sketch
3030
Library // library
31-
Platform // boards platform
32-
PackageIndex // Boards Manager package index
33-
All // any project type
31+
Platform // platform
32+
PackageIndex // package-index
33+
All // all
3434
Not // N/A
3535
)
3636

3737
// FromString parses the --project-type flag value and returns the corresponding project type.
3838
func FromString(projectTypeString string) (Type, error) {
3939
projectType, found := map[string]Type{
40-
"sketch": Sketch,
41-
"library": Library,
42-
"platform": Platform,
43-
"package-index": PackageIndex,
44-
"all": All,
40+
Sketch.String(): Sketch,
41+
Library.String(): Library,
42+
Platform.String(): Platform,
43+
PackageIndex.String(): PackageIndex,
44+
All.String(): All,
4545
}[strings.ToLower(projectTypeString)]
4646

4747
if found {

project/projecttype/type_string.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

result/outputformat/outputformat.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ type Type int
2727

2828
const (
2929
Text Type = iota // text
30-
JSON // JSON
30+
JSON // json
3131
)
3232

3333
// FromString parses the --format flag value and returns the corresponding output format type.
3434
func FromString(outputFormatString string) (Type, error) {
3535
formatType, found := map[string]Type{
36-
"text": Text,
37-
"json": JSON,
36+
Text.String(): Text,
37+
JSON.String(): JSON,
3838
}[strings.ToLower(outputFormatString)]
3939

4040
if found {

result/outputformat/type_string.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)