mirror of
https://github.com/jesseduffield/lazynpm.git
synced 2026-02-20 01:46:44 +08:00
33 lines
842 B
Go
33 lines
842 B
Go
package presentation
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/fatih/color"
|
|
"github.com/jesseduffield/lazynpm/pkg/commands"
|
|
"github.com/jesseduffield/lazynpm/pkg/utils"
|
|
)
|
|
|
|
func GetScriptListDisplayStrings(scripts []*commands.Script, commandMap commands.CommandViewMap) [][]string {
|
|
lines := make([][]string, len(scripts))
|
|
|
|
for i := range scripts {
|
|
script := scripts[i]
|
|
lines[i] = getScriptDisplayStrings(script, commandMap[script.ID()])
|
|
}
|
|
|
|
return lines
|
|
}
|
|
|
|
func getScriptDisplayStrings(p *commands.Script, commandView *commands.CommandView) []string {
|
|
return []string{commandView.Status(), p.Name, utils.ColoredString(p.Command, color.FgBlue)}
|
|
}
|
|
|
|
func ScriptSummary(s *commands.Script) string {
|
|
return fmt.Sprintf(
|
|
"Name: %s\nCommand: %s",
|
|
utils.ColoredString(s.Name, color.FgYellow),
|
|
utils.ColoredString(s.Command, color.FgCyan),
|
|
)
|
|
}
|