Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
Enhance Arm Support info display
Browse files Browse the repository at this point in the history
  • Loading branch information
harryzcy committed Mar 28, 2021
1 parent a58301f commit 47155b5
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/macapp/macapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Application struct {
// Website shows the app's website, empty if unknown
Website string
// ArmSupport shows the Apple Silicon support based on Does It Arm reports
ArmSupport string
ArmSupport remotecheck.Support
}

// GetAllApplications returns all applications
Expand Down
2 changes: 1 addition & 1 deletion internal/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Table(apps []macapp.Application) {
table.SetHeader([]string{"Name", "Current ßArchitectures", "Arm Support"})

for _, app := range apps {
table.Append([]string{app.Name, app.Architectures.String(), app.ArmSupport})
table.Append([]string{app.Name, app.Architectures.String(), app.ArmSupport.String()})
}

table.Render()
Expand Down
6 changes: 3 additions & 3 deletions internal/remotecheck/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (

type AppInfo struct {
Website string
ArmSupport string
ArmSupport Support
}

// Init loads the list of reported app Arm from Does it ARM.
Expand All @@ -39,9 +39,9 @@ func Init() error {
for _, match := range matches {
name := match[1]
info := AppInfo{
Website: match[2],
ArmSupport: match[3],
Website: match[2],
}
info.ArmSupport.Parse(match[3])
infoCache[name] = info
}

Expand Down
2 changes: 1 addition & 1 deletion internal/remotecheck/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ func TestGetInfo(t *testing.T) {

info, err := GetInfo("Go (golang)")
assert.Nil(t, err)
assert.Equal(t, "✅", info.ArmSupport)
assert.Equal(t, SupportNative, info.ArmSupport)
}
57 changes: 57 additions & 0 deletions internal/remotecheck/support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package remotecheck

type Support uint

const (
SupportUndefined Support = iota // zero value
SupportNative
SupportTransition
SupportInDevelopment
SupportNotYet
SupportUnknown
)

func (s *Support) Parse(str string) Support {
switch str {
case "✅":
*s = SupportNative

case "✳️":
*s = SupportTransition

case "⏹":
*s = SupportInDevelopment

case "🚫":
*s = SupportNotYet

case "🔶":
*s = SupportUnknown

}

return *s
}

func (s Support) String() string {
switch s {
case SupportNative:
return "Supported"

case SupportTransition:
return "Supported *"

case SupportInDevelopment:
return "Unsupported"

case SupportNotYet:
return "Unsupported"

case SupportUnknown:
return "Unknown"

default:
return ""

}
}
29 changes: 29 additions & 0 deletions internal/remotecheck/support_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package remotecheck

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestSupport_Parse(t *testing.T) {
tests := []struct {
in string
expected Support
}{
{"✅", SupportNative},
{"✳️", SupportTransition},
{"⏹", SupportInDevelopment},
{"🚫", SupportNotYet},
{"🔶", SupportUnknown},
{"some other", SupportUndefined},
}

for _, test := range tests {
var support Support
actual := support.Parse(test.in)

assert.Equal(t, test.expected, support)
assert.Equal(t, test.expected, actual)
}
}

0 comments on commit 47155b5

Please sign in to comment.