MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / getTaskMappers

Function getTaskMappers

pkg/cmd/task/wait/wait.go:263–309  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

261}
262
263func getTaskMappers() output.Mappers[*tasks.Task] {
264 return output.Mappers[*tasks.Task]{
265 Json: func(task *tasks.Task) any {
266 var duration string
267 if task.StartTime != nil && task.CompletedTime != nil {
268 duration = task.CompletedTime.Sub(*task.StartTime).Round(time.Second).String()
269 }
270 return TaskAsJson{
271 Id: task.ID,
272 Description: task.Description,
273 State: task.State,
274 StartTime: task.StartTime,
275 CompletedTime: task.CompletedTime,
276 Duration: duration,
277 FinishedSuccessfully: task.FinishedSuccessfully,
278 }
279 },
280 Table: output.TableDefinition[*tasks.Task]{
281 Header: []string{"ID", "DESCRIPTION", "STATE", "STARTED", "COMPLETED", "DURATION"},
282 Row: func(task *tasks.Task) []string {
283 var startTime, completedTime, duration string
284 if task.StartTime != nil {
285 startTime = task.StartTime.Format("02-01-2006 15:04:05")
286 }
287 if task.CompletedTime != nil {
288 completedTime = task.CompletedTime.Format("02-01-2006 15:04:05")
289 }
290 if task.StartTime != nil && task.CompletedTime != nil {
291 duration = task.CompletedTime.Sub(*task.StartTime).Round(time.Second).String()
292 }
293
294 state := task.State
295 switch task.State {
296 case "Failed", "TimedOut":
297 state = output.Red(task.State)
298 case "Success":
299 state = output.Green(task.State)
300 case "Queued", "Executing", "Cancelling", "Canceled":
301 state = output.Yellow(task.State)
302 }
303
304 return []string{task.ID, task.Description, state, startTime, completedTime, duration}
305 },
306 },
307 Basic: nil, // Not used - we use the existing formatter for basic output
308 }
309}
310
311func shouldUseCustomOutputFormat(opts *WaitOptions, t *tasks.Task) bool {
312 if opts.Command == nil {

Callers 1

Calls 3

RedFunction · 0.92
GreenFunction · 0.92
YellowFunction · 0.92

Tested by

no test coverage detected