1 Star 0 Fork 0

FuWah_Cheng/powerline-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
segment-exitcode.go 895 Bytes
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"fmt"
"strconv"
"github.com/justjanne/powerline-go/exitcode"
pwl "github.com/justjanne/powerline-go/powerline"
)
var exitCodes = map[int]string{
1: "ERROR",
2: "USAGE",
127: "NOTFOUND",
}
func getMeaningFromExitCode(exitCode int) string {
if exitCode < 128 {
name, ok := exitCodes[exitCode]
if ok {
return name
}
} else {
name, ok := exitcode.Signals[exitCode-128]
if ok {
return name
}
}
return fmt.Sprintf("%d", exitCode)
}
func segmentExitCode(p *powerline) []pwl.Segment {
var meaning string
if p.cfg.PrevError == 0 {
return []pwl.Segment{}
}
if p.cfg.NumericExitCodes {
meaning = strconv.Itoa(p.cfg.PrevError)
} else {
meaning = getMeaningFromExitCode(p.cfg.PrevError)
}
return []pwl.Segment{{
Name: "exit",
Content: meaning,
Foreground: p.theme.CmdFailedFg,
Background: p.theme.CmdFailedBg,
}}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/neepaer/powerline-go.git
git@gitee.com:neepaer/powerline-go.git
neepaer
powerline-go
powerline-go
master

搜索帮助