项目文件夹

文件
wehub-resource-sync 36b3af2e3d
PR Check / Code Quality: Format (push) Failing after 1s
PR Check / Code Quality: Lint (darwin) (push) Failing after 0s
PR Check / Code Quality: Lint (freebsd) (push) Failing after 1s
PR Check / Code Quality: Lint (windows) (push) Failing after 1s
PR Check / Code Quality: Lint (linux) (push) Failing after 1s
PR Check / Security: Vulnerability Scan (push) Failing after 0s
Update Documentation / update-docs (push) Failing after 2s
PR Check / Code Quality: Vendor (push) Failing after 1s
PR Check / Code Quality: Coverage (push) Failing after 0s
PR Check / Tests: Unit (macos-latest) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04-arm) (push) Has been cancelled
PR Check / Tests: Unit (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:22:06 +08:00

47 行
1.0 KiB
Go

package output
import (
"io"
"github.com/pranshuparmar/witr/pkg/model"
)
func RenderShort(w io.Writer, r model.Result, colorEnabled bool) {
p := NewPrinter(w)
for i, proc := range r.Ancestry {
if i > 0 {
if colorEnabled {
p.Printf("%s → %s", ColorMagenta, ColorReset)
} else {
p.Print(" → ")
}
}
if colorEnabled {
nameColor := ansiString("")
if i == len(r.Ancestry)-1 {
nameColor = ColorGreen
}
p.Printf("%s%s%s (%spid %d%s)", nameColor, ChainName(proc), ColorReset, ColorDim, proc.PID, ColorReset)
} else {
p.Printf("%s (pid %d)", ChainName(proc), proc.PID)
}
}
p.Println()
}
// ChainName returns a display name for an ancestry or child node, falling back
// to the command line and then a placeholder when the process name couldn't be
// read (e.g. a protected or already-exited Windows ancestor that exposes
// neither an image name nor a command line).
func ChainName(p model.Process) string {
if p.Command != "" {
return p.Command
}
if p.Cmdline != "" {
return p.Cmdline
}
return "(unknown)"
}