Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
cli: Fix panic in task cancel when no task id given as arg
Browse files Browse the repository at this point in the history
Fixes #4016
  • Loading branch information
briancain committed Oct 10, 2022
1 parent 9650815 commit eb665e3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/cli/task_cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ func (c *TaskCancelCommand) Run(args []string) int {
}
ctx := c.Ctx

if len(c.args) == 0 && c.flagRunJobId == "" {
c.ui.Output("Task ID or Run Job Id required.\n\n%s", c.Help(), terminal.WithErrorStyle())
return 1
var taskId string
if len(c.args) > 0 {
taskId = c.args[0]
}
taskId := c.args[0]

if c.flagRunJobId != "" && taskId != "" {
if taskId == "" && c.flagRunJobId == "" {
c.ui.Output("Task ID or Run Job Id required.\n\n%s", c.Help(), terminal.WithErrorStyle())
return 1
} else if c.flagRunJobId != "" && taskId != "" {
c.ui.Output("Both Run Job Id and Task Id was supplied, will look up by Task Id", terminal.WithWarningStyle())
}

Expand Down

0 comments on commit eb665e3

Please sign in to comment.