Skip to content

Commit

Permalink
commands: handle task executions without inputs gracefully, closes #582
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgooz committed Nov 26, 2018
1 parent 1a0535b commit 65eee86
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions commands/service_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,20 @@ func (c *serviceExecuteCmd) getData(taskKey string, s *coreapi.Service, dataStru
return string(b), err
}

if c.jsonFile == "" {
if survey.AskOne(&survey.Input{Message: "Enter the filepath to the inputs"}, &c.jsonFile, nil) != nil {
return "", errors.New("no filepath given")
// see if task has no inputs.
for _, task := range s.Tasks {
if task.Key == taskKey {
if len(task.Inputs) == 0 {
return "{}", nil
}
break
}
}

// still no answer then return empty json object
if c.jsonFile == "" {
return "{}", nil
if survey.AskOne(&survey.Input{Message: "Enter the filepath to the inputs"}, &c.jsonFile, nil) != nil {
return "", errors.New("no filepath given")
}
}

content, err := xjson.ReadFile(c.jsonFile)
Expand Down

0 comments on commit 65eee86

Please sign in to comment.