(title string, record lifecycleRecord)
| 249 | } |
| 250 | |
| 251 | func lifecycleBundle(title string, record lifecycleRecord) outputBundle { |
| 252 | rows := []keyValue{ |
| 253 | {Label: lifecycleStatusValue, Value: stringOrDash(record.Status)}, |
| 254 | {Label: lifecycleManagedValue, Value: fmt.Sprintf("%t", record.Managed)}, |
| 255 | {Label: lifecycleManagerValue, Value: stringOrDash(record.Manager)}, |
| 256 | {Label: "Home", Value: stringOrDash(record.HomeDir)}, |
| 257 | {Label: lifecycleMessageValue, Value: stringOrDash(record.Message)}, |
| 258 | } |
| 259 | if record.Recommendation != "" { |
| 260 | rows = append(rows, keyValue{Label: "Recommendation", Value: record.Recommendation}) |
| 261 | } |
| 262 | if record.DaemonStopped { |
| 263 | rows = append(rows, keyValue{Label: "Daemon Stopped", Value: toolBoolTrue}) |
| 264 | } |
| 265 | if len(record.Removed) > 0 { |
| 266 | rows = append(rows, keyValue{Label: "Removed", Value: strings.Join(record.Removed, ", ")}) |
| 267 | } |
| 268 | rows = append(rows, keyValue{Label: "Purged", Value: fmt.Sprintf("%t", record.Purged)}) |
| 269 | |
| 270 | return outputBundle{ |
| 271 | jsonValue: record, |
| 272 | human: func() (string, error) { |
| 273 | return renderHumanSection(title, rows), nil |
| 274 | }, |
| 275 | toon: func() (string, error) { |
| 276 | return renderToonObject( |
| 277 | strings.ToLower(title), |
| 278 | []string{ |
| 279 | lifecycleCommandKey, |
| 280 | lifecycleStatusKey, |
| 281 | lifecycleManagedKey, |
| 282 | lifecycleManagerKey, |
| 283 | "home_dir", |
| 284 | lifecycleMessageKey, |
| 285 | "recommendation", |
| 286 | "daemon_stopped", |
| 287 | lifecycleRemovedKey, |
| 288 | "purged", |
| 289 | }, |
| 290 | []string{ |
| 291 | record.Command, |
| 292 | record.Status, |
| 293 | fmt.Sprintf("%t", record.Managed), |
| 294 | record.Manager, |
| 295 | record.HomeDir, |
| 296 | record.Message, |
| 297 | record.Recommendation, |
| 298 | fmt.Sprintf("%t", record.DaemonStopped), |
| 299 | strings.Join(record.Removed, ", "), |
| 300 | fmt.Sprintf("%t", record.Purged), |
| 301 | }, |
| 302 | ), nil |
| 303 | }, |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | func ensureWriteTargetParent(target aghconfig.WriteTarget) error { |
| 308 | path := strings.TrimSpace(target.Path()) |
no test coverage detected