mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-24 02:24:03 -08:00
chore(ci): replace golint with revive
This commit is contained in:
parent
ed610c13ee
commit
50473767a7
|
@ -15,7 +15,7 @@ linters:
|
|||
- gocyclo
|
||||
- gofmt
|
||||
- goimports
|
||||
- golint
|
||||
- revive
|
||||
- goprintffuncname
|
||||
- gosimple
|
||||
- govet
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
ANSIRegex = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
||||
ansiRegex = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
||||
)
|
||||
|
||||
type ansiUtils struct {
|
||||
|
@ -105,14 +105,14 @@ func (a *ansiUtils) lenWithoutANSI(text string) int {
|
|||
// replace hyperlinks
|
||||
matches := findAllNamedRegexMatch(`(?P<STR>\x1b]8;;file:\/\/(.+)\x1b\\(?P<URL>.+)\x1b]8;;\x1b\\)`, text)
|
||||
for _, match := range matches {
|
||||
text = strings.ReplaceAll(text, match[STR], match[URL])
|
||||
text = strings.ReplaceAll(text, match[str], match[url])
|
||||
}
|
||||
// replace console title
|
||||
matches = findAllNamedRegexMatch(`(?P<STR>\x1b\]0;(.+)\007)`, text)
|
||||
for _, match := range matches {
|
||||
text = strings.ReplaceAll(text, match[STR], "")
|
||||
text = strings.ReplaceAll(text, match[str], "")
|
||||
}
|
||||
stripped := replaceAllString(ANSIRegex, text, "")
|
||||
stripped := replaceAllString(ansiRegex, text, "")
|
||||
stripped = strings.ReplaceAll(stripped, a.escapeLeft, "")
|
||||
stripped = strings.ReplaceAll(stripped, a.escapeRight, "")
|
||||
runeText := []rune(stripped)
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
var (
|
||||
// Map for color names and their respective foreground [0] or background [1] color codes
|
||||
colorMap map[string][2]string = map[string][2]string{
|
||||
colorMap = map[string][2]string{
|
||||
"black": {"30", "40"},
|
||||
"red": {"31", "41"},
|
||||
"green": {"32", "42"},
|
||||
|
|
|
@ -150,7 +150,7 @@ func GetWindowTitle(pid int, windowTitleRegex string) (syscall.Handle, string) {
|
|||
|
||||
// callback fro EnumWindows
|
||||
cb := syscall.NewCallback(func(h syscall.Handle, p uintptr) uintptr {
|
||||
var prcsID int = 0
|
||||
var prcsID int
|
||||
// get pid
|
||||
_, _, _ = procGetWindowThreadProcessID.Call(uintptr(h), uintptr(unsafe.Pointer(&prcsID)))
|
||||
// check if pid matches spotify pid
|
||||
|
|
25
src/image.go
25
src/image.go
|
@ -41,10 +41,11 @@ const (
|
|||
green = "#71BD47"
|
||||
|
||||
// known ansi sequences
|
||||
FG = "FG"
|
||||
BG = "BG"
|
||||
STR = "STR"
|
||||
URL = "URL"
|
||||
|
||||
fg = "FG"
|
||||
bg = "BG"
|
||||
str = "STR"
|
||||
url = "URL"
|
||||
invertedColor = "inverted"
|
||||
invertedColorSingle = "invertedsingle"
|
||||
fullColor = "full"
|
||||
|
@ -355,24 +356,24 @@ func (ir *ImageRenderer) shouldPrint() bool {
|
|||
if len(match) == 0 {
|
||||
continue
|
||||
}
|
||||
ir.ansiString = strings.TrimPrefix(ir.ansiString, match[STR])
|
||||
ir.ansiString = strings.TrimPrefix(ir.ansiString, match[str])
|
||||
switch sequence {
|
||||
case invertedColor:
|
||||
ir.foregroundColor = ir.defaultBackgroundColor
|
||||
ir.backgroundColor = NewRGBColor(match[BG])
|
||||
ir.backgroundColor = NewRGBColor(match[bg])
|
||||
return false
|
||||
case invertedColorSingle:
|
||||
ir.foregroundColor = ir.defaultBackgroundColor
|
||||
color, _ := strconv.Atoi(match[BG])
|
||||
color, _ := strconv.Atoi(match[bg])
|
||||
color += 10
|
||||
ir.setBase16Color(fmt.Sprint(color))
|
||||
return false
|
||||
case fullColor:
|
||||
ir.foregroundColor = NewRGBColor(match[FG])
|
||||
ir.backgroundColor = NewRGBColor(match[BG])
|
||||
ir.foregroundColor = NewRGBColor(match[fg])
|
||||
ir.backgroundColor = NewRGBColor(match[bg])
|
||||
return false
|
||||
case foreground:
|
||||
ir.foregroundColor = NewRGBColor(match[FG])
|
||||
ir.foregroundColor = NewRGBColor(match[fg])
|
||||
return false
|
||||
case reset:
|
||||
ir.foregroundColor = ir.defaultForegroundColor
|
||||
|
@ -387,10 +388,10 @@ func (ir *ImageRenderer) shouldPrint() bool {
|
|||
case strikethrough, strikethroughReset, left, osc99, lineChange, title:
|
||||
return false
|
||||
case color16:
|
||||
ir.setBase16Color(match[FG])
|
||||
ir.setBase16Color(match[fg])
|
||||
return false
|
||||
case link:
|
||||
ir.ansiString = match[URL] + ir.ansiString
|
||||
ir.ansiString = match[url] + ir.ansiString
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -210,7 +210,7 @@ func main() {
|
|||
}
|
||||
imageCreator.init()
|
||||
match := findNamedRegexMatch(`.*(\/|\\)(?P<STR>.+).omp.(json|yaml|toml)`, *args.Config)
|
||||
err := imageCreator.SavePNG(fmt.Sprintf("%s.png", match[STR]))
|
||||
err := imageCreator.SavePNG(fmt.Sprintf("%s.png", match[str]))
|
||||
if err != nil {
|
||||
fmt.Print(err.Error())
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
regexCache map[string]*regexp.Regexp = make(map[string]*regexp.Regexp)
|
||||
regexCache = make(map[string]*regexp.Regexp)
|
||||
regexCacheLock = sync.RWMutex{}
|
||||
)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ func bootStrapKubectlTest(args *kubectlArgs) *kubectl {
|
|||
env := new(MockedEnvironment)
|
||||
env.On("hasCommand", "kubectl").Return(args.kubectlExists)
|
||||
kubectlOut := args.context + "," + args.namespace
|
||||
var kubectlErr error = nil
|
||||
var kubectlErr error
|
||||
if args.kubectlErr {
|
||||
kubectlErr = &commandError{
|
||||
err: "oops",
|
||||
|
|
Loading…
Reference in a new issue