Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workflow show command output incorrect JSON #192

Merged
merged 1 commit into from
May 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions cli/workflowCommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ func (h *historyIterator) Next() (interface{}, error) {

// helper function to print workflow progress with time refresh every second
func printWorkflowProgress(c *cli.Context, wid, rid string, watch bool) error {
outputFormat := output.Table
if c.IsSet(output.FlagOutput) {
outputFlag := c.String(output.FlagOutput)
outputFormat = output.OutputOption(outputFlag)
}

var maxFieldLength = c.Int(FlagMaxFieldLength)
sdkClient, err := getSDKClient(c)
if err != nil {
Expand All @@ -323,7 +329,10 @@ func printWorkflowProgress(c *cli.Context, wid, rid string, watch bool) error {
Fields: []string{"ID", "Time", "Type"},
FieldsLong: []string{"Details"},
}
fmt.Println(color.Magenta(c, "Progress:"))
if outputFormat != output.JSON {
fmt.Println(color.Magenta(c, "Progress:"))
}

var lastEvent historypb.HistoryEvent // used for print result of this run

errChan := make(chan error)
Expand All @@ -346,18 +355,23 @@ func printWorkflowProgress(c *cli.Context, wid, rid string, watch bool) error {
continue
}

if isTimeElapseExist {
removePrevious2LinesFromTerminal()
if outputFormat != output.JSON {
if isTimeElapseExist {
removePrevious2LinesFromTerminal()
}
fmt.Printf("\nTime elapse: %ds\n", timeElapse)
}
fmt.Printf("\nTime elapse: %ds\n", timeElapse)

isTimeElapseExist = true
timeElapse++
case <-doneChan: // print result of this run
fmt.Println(color.Magenta(c, "\nResult:"))
if watch {
fmt.Printf(" Run Time: %d seconds\n", timeElapse)
if outputFormat != output.JSON {
fmt.Println(color.Magenta(c, "\nResult:"))
if watch {
fmt.Printf(" Run Time: %d seconds\n", timeElapse)
}
printRunStatus(c, &lastEvent)
}
printRunStatus(c, &lastEvent)
return nil
case err = <-errChan:
return err
Expand Down