Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
per1234 committed Dec 14, 2020
commit 0862c544b4b301b7ba30124f8447d69c8fe6f1a7
14 changes: 7 additions & 7 deletions configuration/checkmode/checkmode.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const (
Strict Type = iota // strict
Specification // specification
Permissive // permissive
LibraryManagerSubmission // --library-manager=submit
LibraryManagerIndexed // --library-manager=update
LibraryManagerSubmission // submit
LibraryManagerIndexed // update
Official // ARDUINO_CHECK_OFFICIAL
Default // default
)
Expand All @@ -54,11 +54,11 @@ var Types = map[Type]struct{}{
// ComplianceModeFromString parses the --compliance flag value and returns the corresponding check mode settings.
func ComplianceModeFromString(complianceModeString string) (bool, bool, bool, error) {
switch strings.ToLower(complianceModeString) {
case "strict":
case Strict.String():
return true, false, false, nil
case "specification":
case Specification.String():
return false, true, false, nil
case "permissive":
case Permissive.String():
return false, false, true, nil
default:
return false, false, false, fmt.Errorf("No matching compliance mode for string %s", complianceModeString)
Expand All @@ -68,9 +68,9 @@ func ComplianceModeFromString(complianceModeString string) (bool, bool, bool, er
// LibraryManagerModeFromString parses the --library-manager flag value and returns the corresponding check mode settings.
func LibraryManagerModeFromString(libraryManagerModeString string) (bool, bool, error) {
switch strings.ToLower(libraryManagerModeString) {
case "submit":
case LibraryManagerSubmission.String():
return true, false, nil
case "update":
case LibraryManagerIndexed.String():
return false, true, nil
case "false":
return false, false, nil
Expand Down
4 changes: 2 additions & 2 deletions configuration/checkmode/type_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions project/projecttype/projecttype.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ type Type int
const (
Sketch Type = iota // sketch
Library // library
Platform // boards platform
PackageIndex // Boards Manager package index
All // any project type
Platform // platform
PackageIndex // package-index
All // all
Not // N/A
)

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

if found {
Expand Down
4 changes: 2 additions & 2 deletions project/projecttype/type_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions result/outputformat/outputformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ type Type int

const (
Text Type = iota // text
JSON // JSON
JSON // json
)

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

if found {
Expand Down
2 changes: 1 addition & 1 deletion result/outputformat/type_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.