MCPcopy Create free account
hub / github.com/cloudbase/garm / formatOneObject

Function formatOneObject

cmd/garm-cli/cmd/file_object.go:509–535  ·  view source on GitHub ↗
(fileObj params.FileObject)

Source from the content-addressed store, hash-verified

507}
508
509func formatOneObject(fileObj params.FileObject) {
510 if outputFormat == common.OutputFormatJSON {
511 printAsJSON(fileObj)
512 return
513 }
514 t := table.NewWriter()
515 t.Style().Options.SeparateHeader = true
516 header := table.Row{"Field", "Value"}
517 t.AppendHeader(header)
518 t.AppendRow([]interface{}{"ID", fileObj.ID})
519 t.AppendRow([]interface{}{"Name", fileObj.Name})
520 t.AppendRow([]interface{}{"Created At", fileObj.CreatedAt})
521 t.AppendRow([]interface{}{"Updated At", fileObj.UpdatedAt})
522 t.AppendRow([]interface{}{"Size", fileObj.Size})
523 t.AppendRow([]interface{}{"SHA256SUM", fileObj.SHA256})
524 t.AppendRow([]interface{}{"File Type", fileObj.FileType})
525 t.AppendRow([]interface{}{"Description", fileObj.Description})
526
527 if len(fileObj.Tags) > 0 {
528 t.AppendRow([]interface{}{"Tags", strings.Join(fileObj.Tags, ", ")})
529 }
530 t.SetColumnConfigs([]table.ColumnConfig{
531 {Number: 1, AutoMerge: true},
532 {Number: 2, AutoMerge: false, WidthMax: 100},
533 })
534 fmt.Println(t.Render())
535}
536
537func formatFileObjsList(files params.FileObjectPaginatedResponse) {
538 if outputFormat == common.OutputFormatJSON {

Callers 2

file_object.goFile · 0.85
controller.goFile · 0.85

Calls 1

printAsJSONFunction · 0.85

Tested by

no test coverage detected