func printInfo(d *gdrive.Drive, f *drive.File, sizeInBytes bool) { fields := map[string]string{ "Id": f.Id, "Title": f.Title, "Description": f.Description, "Size": util.FileSizeFormat(f.FileSize, sizeInBytes), "Created": util.ISODateToLocal(f.CreatedDate), "Modified": util.ISODateToLocal(f.ModifiedDate), "Owner": strings.Join(f.OwnerNames, ", "), "Md5sum": f.Md5Checksum, "Shared": util.FormatBool(isShared(d, f.Id)), "Parents": util.ParentList(f.Parents), } order := []string{ "Id", "Title", "Description", "Size", "Created", "Modified", "Owner", "Md5sum", "Shared", "Parents", } util.Print(fields, order) }
func List(d *gdrive.Drive, query, titleFilter string, maxResults int, sharedStatus, noHeader, includeDocs, sizeInBytes bool) error { files, err := queryAll(d, query, titleFilter, maxResults, includeDocs) if err != nil { return err } items := make([]map[string]string, 0, 0) for _, f := range files { if maxResults > 0 && len(items) >= maxResults { break } items = append(items, map[string]string{ "Id": f.Id, "Title": util.TruncateString(f.Title, 40), "Size": util.FileSizeFormat(f.FileSize, sizeInBytes), "Created": util.ISODateToLocal(f.CreatedDate), }) } columnOrder := []string{"Id", "Title", "Size", "Created"} if sharedStatus { addSharedStatus(d, items) columnOrder = append(columnOrder, "Shared") } util.PrintColumns(items, columnOrder, 3, noHeader) return nil }