Skip to content

Commit cdf55dc

Browse files
authored
Merge pull request #74 from trickest/feature/completed-run-status
Add completed run status and specific run ID to the get command
2 parents 8560f5a + 4dc48a8 commit cdf55dc

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

cmd/get/get.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import (
77
"trickest-cli/cmd/execute"
88
"trickest-cli/cmd/list"
99
"trickest-cli/cmd/output"
10+
"trickest-cli/types"
1011
"trickest-cli/util"
1112

13+
"github.com/google/uuid"
1214
"github.com/spf13/cobra"
1315
)
1416

1517
var (
1618
watch bool
1719
showNodeParams bool
20+
runID string
1821
)
1922

2023
// GetCmd represents the get command
@@ -45,8 +48,19 @@ var GetCmd = &cobra.Command{
4548
version := execute.GetLatestWorkflowVersion(workflow.ID)
4649
allNodes, roots := execute.CreateTrees(version, false)
4750

48-
runs := output.GetRuns(version.WorkflowInfo, 1)
49-
if runs != nil && len(runs) > 0 && runs[0].Status == "RUNNING" {
51+
var runs []types.Run
52+
if runID == "" {
53+
runs = output.GetRuns(version.WorkflowInfo, 1)
54+
} else {
55+
runUUID, err := uuid.Parse(runID)
56+
if err != nil {
57+
fmt.Println("Invalid run ID")
58+
return
59+
}
60+
run := execute.GetRunByID(runUUID)
61+
runs = []types.Run{*run}
62+
}
63+
if runs != nil && len(runs) > 0 && (runs[0].Status == "RUNNING" || runs[0].Status == "COMPLETED") {
5064
execute.WatchRun(runs[0].ID, "", map[string]output.NodeInfo{}, !watch, &runs[0].Bees, showNodeParams)
5165
return
5266
} else {
@@ -77,4 +91,5 @@ var GetCmd = &cobra.Command{
7791
func init() {
7892
GetCmd.Flags().BoolVar(&watch, "watch", false, "Watch the workflow execution if it's still running")
7993
GetCmd.Flags().BoolVar(&showNodeParams, "show-params", false, "Show parameters in the workflow tree")
94+
GetCmd.Flags().StringVar(&runID, "run", "", "Get the status of a specific run")
8095
}

0 commit comments

Comments
 (0)