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

cli: add include-last-command flag to list and status commands #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions client/operations/get_workflow_status_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions client/operations/get_workflow_status_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions client/operations/get_workflows_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions client/operations/get_workflows_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

149 changes: 145 additions & 4 deletions client/operations/launch_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type listOptions struct {
includeDuration bool
includeProgress bool
includeWorkspaceSize bool
includeLastCommand bool
showDeletedRuns bool
page int64
size int64
Expand Down Expand Up @@ -131,6 +132,12 @@ In case a workflow is in progress, its duration as of now will be shown.`,
false,
"Include size information of the workspace.",
)
f.BoolVar(
&o.includeLastCommand,
"include-last-command",
false,
"Include the information about the last command executed (or currently in execution) by the workflow.",
)
f.BoolVar(
&o.showDeletedRuns,
"show-deleted-runs",
Expand Down Expand Up @@ -180,6 +187,9 @@ func (o *listOptions) run(cmd *cobra.Command) error {
if cmd.Flags().Changed("include-workspace-size") {
listParams.SetIncludeWorkspaceSize(&o.includeWorkspaceSize)
}
if cmd.Flags().Changed("include-last-command") {
listParams.SetIncludeLastCommand(&o.includeLastCommand)
}

api, err := client.ApiClient()
if err != nil {
Expand All @@ -196,6 +206,7 @@ func (o *listOptions) run(cmd *cobra.Command) error {
o.includeWorkspaceSize,
o.includeProgress,
o.includeDuration,
o.includeLastCommand,
)
parsedFormatFilters := formatter.ParseFormatParameters(o.formatFilters, true)
err = displayListPayload(
Expand Down Expand Up @@ -279,6 +290,11 @@ func displayListPayload(
}
case "session_status":
value = getOptionalStringField(&workflow.SessionStatus)
case "last_command":
value = workflows.GetLastCommand(
workflow.Progress.CurrentCommand,
workflow.Progress.CurrentStepName,
)
}

colSeries.Append(value)
Expand Down Expand Up @@ -313,7 +329,7 @@ func displayListPayload(
// verbose information, workspace size, progress and duration.
func buildListHeader(
runType string,
verbose, includeWorkspaceSize, includeProgress, includeDuration bool,
verbose, includeWorkspaceSize, includeProgress, includeDuration, includeLastCommand bool,
) []string {
headers := map[string][]string{
"batch": {"name", "run_number", "created", "started", "ended", "status"},
Expand All @@ -340,6 +356,9 @@ func buildListHeader(
if verbose || includeDuration {
header = append(header, "duration")
}
if verbose || includeLastCommand {
header = append(header, "last_command")
}

return header
}
Expand Down
Loading