aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/cli.go8
-rw-r--r--drive.go8
2 files changed, 9 insertions, 7 deletions
diff --git a/cli/cli.go b/cli/cli.go
index 49ba1e7..764a42a 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -13,7 +13,7 @@ import (
"strings"
)
-func List(d *gdrive.Drive, query, titleFilter string, maxResults int, sharedStatus bool, noHeader bool, includeDocs bool) error {
+func List(d *gdrive.Drive, query, titleFilter string, maxResults int, sharedStatus, noHeader, includeDocs, sizeInBytes bool) error {
caller := d.Files.List()
if maxResults > 0 {
@@ -49,7 +49,7 @@ func List(d *gdrive.Drive, query, titleFilter string, maxResults int, sharedStat
items = append(items, map[string]string{
"Id": f.Id,
"Title": util.TruncateString(f.Title, 40),
- "Size": util.FileSizeFormat(f.FileSize, false),
+ "Size": util.FileSizeFormat(f.FileSize, sizeInBytes),
"Created": util.ISODateToLocal(f.CreatedDate),
})
}
@@ -96,12 +96,12 @@ func addSharedStatus(d *gdrive.Drive, items []map[string]string) {
}
}
-func Info(d *gdrive.Drive, fileId string) error {
+func Info(d *gdrive.Drive, fileId string, sizeInBytes bool) error {
info, err := d.Files.Get(fileId).Do()
if err != nil {
return fmt.Errorf("An error occurred: %v\n", err)
}
- printInfo(d, info, false)
+ printInfo(d, info, sizeInBytes)
return nil
}
diff --git a/drive.go b/drive.go
index 1786e68..667d0eb 100644
--- a/drive.go
+++ b/drive.go
@@ -29,10 +29,12 @@ type Options struct {
Query string `goptions:"-q, --query, mutexgroup='query', description='Query (see https://developers.google.com/drive/search-parameters)'"`
SharedStatus bool `goptions:"-s, --shared, description='Show shared status (Note: this will generate 1 http req per file)'"`
NoHeader bool `goptions:"-n, --noheader, description='Do not show the header'"`
+ SizeInBytes bool `goptions:"--bytes, description='Show size in bytes'"`
} `goptions:"list"`
Info struct {
- FileId string `goptions:"-i, --id, obligatory, description='File Id'"`
+ FileId string `goptions:"-i, --id, obligatory, description='File Id'"`
+ SizeInBytes bool `goptions:"--bytes, description='Show size in bytes'"`
} `goptions:"info"`
Folder struct {
@@ -102,10 +104,10 @@ func main() {
switch opts.Verbs {
case "list":
args := opts.List
- err = cli.List(drive, args.Query, args.TitleFilter, args.MaxResults, args.SharedStatus, args.NoHeader, args.IncludeDocs)
+ err = cli.List(drive, args.Query, args.TitleFilter, args.MaxResults, args.SharedStatus, args.NoHeader, args.IncludeDocs, args.SizeInBytes)
case "info":
- err = cli.Info(drive, opts.Info.FileId)
+ err = cli.Info(drive, opts.Info.FileId, opts.Info.SizeInBytes)
case "folder":
args := opts.Folder