优化Zsh插件安装流程和命令执行器

- 重构Zsh插件安装逻辑,将硬编码URL拆分为源和目标路径
- 修改RealTimeCommandExecutor,增加实时命令执行日志输出
- 优化SingleLineCommandExecutor日志信息,改进命令日志可读性
- 简化插件安装命令,支持国内外镜像源的插件克隆
This commit is contained in:
zeaslity
2025-03-11 16:14:28 +08:00
parent 34b5f80704
commit 8e4444a7cc
2 changed files with 27 additions and 21 deletions

View File

@@ -18,12 +18,12 @@ import (
// []string - 合并后的标准输出和标准错误内容(按行分割)
func SingleLineCommandExecutor(singleLineCommand []string) (ok bool, resultLog []string) {
log.Info("start => %v", singleLineCommand)
if len(singleLineCommand) == 0 {
return false, nil
}
log.Info("start => %v", strings.Join(singleLineCommand, " "))
// 创建命令实例
cmd := exec.Command(singleLineCommand[0], singleLineCommand[1:]...)
@@ -89,7 +89,7 @@ func PipeLineCommandExecutor(pipeLineCommand [][]string) (ok bool, resultLog []s
if len(cmd) == 0 {
return false, nil
}
pipeLineCommandStr += fmt.Sprintf("%v | ", cmd)
pipeLineCommandStr += fmt.Sprintf("%s | ", strings.Join(cmd, " "))
}
pipeLineCommandStr = strings.TrimSuffix(pipeLineCommandStr, " | ")
@@ -181,6 +181,8 @@ func RealTimeCommandExecutor(realTimeCommand []string) (ok bool, resultLog []str
return false, nil
}
log.Info("start real time command => %v", strings.Join(realTimeCommand, " "))
cmd := exec.Command(realTimeCommand[0], realTimeCommand[1:]...)
stdout, err := cmd.StdoutPipe()