| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 | package drive
import (
    "io"
    "fmt"
    "text/tabwriter"
)
type AboutArgs struct {
    Out io.Writer
    SizeInBytes bool
}
func (self *Drive) About(args AboutArgs) (err error) {
    about, err := self.service.About.Get().Fields("maxImportSizes", "maxUploadSize", "storageQuota", "user").Do()
    if err != nil {
        return fmt.Errorf("Failed to get about: %s", err)
    }
    user := about.User
    quota := about.StorageQuota
    fmt.Fprintf(args.Out, "User: %s, %s\n", user.DisplayName, user.EmailAddress)
    fmt.Fprintf(args.Out, "Used: %s\n", formatSize(quota.UsageInDrive, args.SizeInBytes))
    fmt.Fprintf(args.Out, "Free: %s\n", formatSize(quota.Limit - quota.UsageInDrive, args.SizeInBytes))
    fmt.Fprintf(args.Out, "Total: %s\n", formatSize(quota.Limit, args.SizeInBytes))
    fmt.Fprintf(args.Out, "Max upload size: %s\n", formatSize(about.MaxUploadSize, args.SizeInBytes))
    return
}
type AboutImportArgs struct {
    Out io.Writer
}
func (self *Drive) AboutImport(args AboutImportArgs) (err error) {
    about, err := self.service.About.Get().Fields("importFormats").Do()
    if err != nil {
        return fmt.Errorf("Failed to get about: %s", err)
    }
    printAboutFormats(args.Out, about.ImportFormats)
    return
}
type AboutExportArgs struct {
    Out io.Writer
}
func (self *Drive) AboutExport(args AboutExportArgs) (err error) {
    about, err := self.service.About.Get().Fields("exportFormats").Do()
    if err != nil {
        return fmt.Errorf("Failed to get about: %s", err)
    }
    printAboutFormats(args.Out, about.ExportFormats)
    return
}
func printAboutFormats(out io.Writer, formats map[string][]string) {
    w := new(tabwriter.Writer)
    w.Init(out, 0, 0, 3, ' ', 0)
    fmt.Fprintln(w, "From\tTo")
    for from, toFormats := range formats {
        fmt.Fprintf(w, "%s\t%s\n", from, formatList(toFormats))
    }
    w.Flush()
}
 |