-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Highlight Specific Dependencies (#23)
* feat($atlas): add highlight flag Signed-off-by: Rain Wu <[email protected]>
- Loading branch information
1 parent
492b4db
commit e270c01
Showing
4 changed files
with
120 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,57 @@ | ||
package telescope | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type OutdatedScope int | ||
|
||
const ( | ||
MAJOR OutdatedScope = iota | ||
UP_TO_DATE OutdatedScope = iota | ||
MAJOR | ||
MINOR | ||
PATCH | ||
UP_TO_DATE | ||
UNKNOWN | ||
) | ||
|
||
var OutdatedScopeLiteral [5]string = [...]string{"UP_TO_DATE", "MAJOR", "MINOR", "PATCH", "UNKNOWN"} | ||
|
||
var MapScopeColor map[OutdatedScope]int = map[OutdatedScope]int{ | ||
UP_TO_DATE: 92, | ||
MAJOR: 91, | ||
MINOR: 93, | ||
PATCH: 94, | ||
UP_TO_DATE: 92, | ||
UNKNOWN: 97, | ||
} | ||
|
||
func (o OutdatedScope) String() string { | ||
return [...]string{"MAJOR", "MINOR", "PATCH", "UP_TO_DATE", "UNKNOWN"}[o] | ||
return OutdatedScopeLiteral[o] | ||
} | ||
|
||
func OutdatedScopeStrToEnum(scopeStr string) OutdatedScope { | ||
|
||
scopeStr = strings.ToUpper(scopeStr) | ||
for idx, scp := range [...]string{"MAJOR", "MINOR", "PATCH"} { | ||
for idx, scp := range OutdatedScopeLiteral { | ||
if scopeStr == scp { | ||
return OutdatedScope(idx) | ||
} | ||
} | ||
panic(fmt.Errorf("unknown scope %s", scopeStr)) | ||
} | ||
|
||
func GetTopScope(scopes []OutdatedScope) OutdatedScope { | ||
|
||
if len(scopes) == 0 { | ||
panic(errors.New("should provide at least one item")) | ||
} | ||
|
||
var hold OutdatedScope = UNKNOWN | ||
for _, scp := range scopes { | ||
if scp < hold { | ||
hold = scp | ||
} | ||
} | ||
return hold | ||
} |