func fileSizesInfo(logy *log.Logger, about *drive.About) { if len(about.MaxUploadSizes) >= 1 { logy.Logln("\n* Maximum upload sizes per file type *") logy.Logf("%-50s %-20s\n", "FileType", "Size") for _, uploadInfo := range about.MaxUploadSizes { logy.Logf("%-50s %-20s\n", uploadInfo.Type, prettyBytes(uploadInfo.Size)) } logy.Logln() } return }
func featuresInformation(logy *log.Logger, about *drive.About) { if len(about.Features) >= 1 { logy.Logf("%-30s %-30s\n", "Feature", "Request limit (queries/second)") for _, feature := range about.Features { if feature.FeatureName == "" { continue } logy.Logf("%-30s %-30f\n", feature.FeatureName, feature.FeatureRate) } logy.Logln() } }
func printChangeList(logy *log.Logger, changes []*Change, noPrompt bool, noClobber bool) (bool, *map[Operation]sizeCounter) { if len(changes) == 0 { logy.Logln("Everything is up-to-date.") return false, nil } if noPrompt { return true, nil } opMap := opChangeCount(changes) previewChanges(logy, changes, true, opMap) return promptForChanges(), &opMap }
func previewChanges(logy *log.Logger, cl []*Change, reduce bool, opMap map[Operation]sizeCounter) { for _, c := range cl { op := c.Op() if op != OpNone { logy.Logln(c.Symbol(), c.Path) } } if reduce { for op, counter := range opMap { if counter.count < 1 { continue } _, name := op.description() logy.Logf("%s %s\n", name, counter.String()) } } }
func (f *File) pretty(logy *log.Logger, opt attribute) { fmtdPath := sepJoin("/", opt.parent, f.Name) if opt.diskUsageOnly { logy.Logf("%-12v %s\n", f.Size, fmtdPath) return } if opt.minimal { logy.Logf("%s ", fmtdPath) } else { if f.IsDir { logy.Logf("d") } else { logy.Logf("-") } if f.Shared { logy.Logf("s") } else { logy.Logf("-") } if f.UserPermission != nil { logy.Logf(" %-10s ", f.UserPermission.Role) } } if owners(opt.mask) && len(f.OwnerNames) >= 1 { logy.Logf(" %s ", strings.Join(f.OwnerNames, " & ")) } if version(opt.mask) { logy.Logf(" v%d", f.Version) } if !opt.minimal { logy.Logf(" %-10s\t%-10s\t\t%-20s\t%-50s\n", prettyBytes(f.Size), f.Id, f.ModTime, fmtdPath) } else { logy.Logln() } }
func quotaInformation(logy *log.Logger, about *drive.About) { freeBytes := about.QuotaBytesTotal - about.QuotaBytesUsed logy.Logf( "Name: %s\nAccount type:\t%s\nBytes Used:\t%-20d (%s)\n"+ "Bytes Free:\t%-20d (%s)\nBytes InTrash:\t%-20d (%s)\n"+ "Total Bytes:\t%-20d (%s)\n", about.Name, about.QuotaType, about.QuotaBytesUsed, prettyBytes(about.QuotaBytesUsed), freeBytes, prettyBytes(freeBytes), about.QuotaBytesUsedInTrash, prettyBytes(about.QuotaBytesUsedInTrash), about.QuotaBytesTotal, prettyBytes(about.QuotaBytesTotal)) if len(about.QuotaBytesByService) >= 1 { logy.Logln("\n* Space used by Google Services *") logy.Logf("%-36s %-36s\n", "Service", "Bytes") for _, quotaService := range about.QuotaBytesByService { logy.Logf("%-36s %-36s\n", quotaService.ServiceName, prettyBytes(quotaService.BytesUsed)) } logy.Logf("%-36s %-36s\n", "Space used by all Google Apps", prettyBytes(about.QuotaBytesUsedAggregate)) } logy.Logln() }
func showPromptShareChanges(logy *log.Logger, change *shareChange) Agreement { if len(change.files) < 1 { return NotApplicable } if change.revoke { logy.Logf("Revoke access for accountType: \033[92m%s\033[00m for file(s):\n", change.accountType.String()) for _, file := range change.files { logy.Logln("+ ", file.Name) } logy.Logln() return promptForChanges() } if len(change.emails) < 1 { return NotApplicable } if change.notify { logy.Logln("Message:\n\t", change.emailMessage) } logy.Logln("Receipients:") for _, email := range change.emails { logy.Logf("\t\033[92m+\033[00m %s\n", email) } logy.Logln("\nFile(s) to share:") for _, file := range change.files { if file == nil { continue } logy.Logf("\t\033[92m+\033[00m %s\n", file.Name) } return promptForChanges() }
func showPromptShareChanges(logy *log.Logger, change *shareChange) Agreement { if len(change.files) < 1 { return NotApplicable } verb := "unshare" shareInfo := "Revoke access" extraShareInfo := "" if !change.revoke { shareInfo = "Provide access" if len(change.emails) < 1 { return NotApplicable } verb = "share" if change.notify && len(change.emailMessage) >= 1 { extraShareInfo = fmt.Sprintf("Message:\n\t\033[33m%s\033[00m\n", change.emailMessage) } } if len(change.accountTypes) >= 1 { logy.Logf("%s for accountType(s)\n", shareInfo) for _, accountType := range change.accountTypes { logy.Logf("\t\033[32m%s\033[00m\n", accountType.String()) } logy.Logln(extraShareInfo) } if len(change.roles) >= 1 { logy.Logln("For roles(s)") for _, role := range change.roles { logy.Logf("\t\033[33m%s\033[00m\n", role.String()) } } if len(change.emails) >= 1 { logy.Logf("\nAddressees:\n") for _, email := range change.emails { logy.Logf("\t\033[92m+\033[00m %s\n", email) } } logy.Logf("\nFile(s) to %s:\n", verb) for _, file := range change.files { if file == nil { continue } logy.Logf("\t\033[92m+\033[00m %s\n", file.Name) } logy.Logln() return promptForChanges() }