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