MCPcopy Create free account
hub / github.com/astercloud/aster / buildCommand

Method buildCommand

pkg/tools/builtin/task_manager.go:358–378  ·  view source on GitHub ↗

buildCommand 构建命令

(cmd string, opts *TaskOptions)

Source from the content-addressed store, hash-verified

356
357// buildCommand 构建命令
358func (tm *FileTaskManager) buildCommand(cmd string, opts *TaskOptions) string {
359 var parts []string
360
361 // 添加环境变量
362 for k, v := range opts.Env {
363 parts = append(parts, fmt.Sprintf("export %s='%s'", k, strings.ReplaceAll(v, "'", "'\"'\"'")))
364 }
365
366 // 添加命令
367 parts = append(parts, cmd)
368
369 // 根据shell类型构建
370 switch opts.Shell {
371 case "sh":
372 return fmt.Sprintf("sh -c '%s'", strings.Join(parts, "; "))
373 case "zsh":
374 return fmt.Sprintf("zsh -c '%s'", strings.Join(parts, "; "))
375 default: // bash
376 return fmt.Sprintf("bash -c '%s'", strings.Join(parts, "; "))
377 }
378}
379
380// monitorTask 监控任务执行
381func (tm *FileTaskManager) monitorTask(ctx context.Context, task *TaskInfo, cmd *exec.Cmd) {

Callers 1

StartTaskMethod · 0.95

Calls 1

JoinMethod · 0.45

Tested by

no test coverage detected