webcmd: allow setting custom WorkingDir for process

This commit is contained in:
mappu 2017-03-25 15:58:55 +13:00
parent 7dde122d9b
commit 68c25fa139
3 changed files with 7 additions and 4 deletions

View File

@ -41,7 +41,7 @@ func uuid() string {
}
// LaunchTask creates a new task from the given command parameters.
func (this *App) LaunchTask(params []string) (taskRef string, err error) {
func (this *App) LaunchTask(workDir string, params []string) (taskRef string, err error) {
if len(params) == 0 {
return "", errors.New("No parameters for task")
}
@ -60,6 +60,8 @@ func (this *App) LaunchTask(params []string) (taskRef string, err error) {
return "", err
}
cmd.Dir = workDir
err = cmd.Start()
if err != nil {
return "", err

View File

@ -22,8 +22,9 @@ type InputParam struct {
}
type CommandConfig struct {
Title string
Execution []InputParam // TODO allow plain strings as a shorthand for PARAMTYPE_CONST
Title string
WorkingDir string // default empty-string: getcwd()
Execution []InputParam // TODO allow plain strings as a shorthand for PARAMTYPE_CONST
}
type AppConfig struct {

View File

@ -58,7 +58,7 @@ func (this *App) Action_NewTask(w http.ResponseWriter, r *http.Request) {
}
// Create new command from supplied values
taskRef, err := this.LaunchTask(params)
taskRef, err := this.LaunchTask(taskInfo.WorkingDir, params)
if err != nil {
fail(w, r, err.Error())
return