diff options
| -rw-r--r-- | drive/files.go | 1 | ||||
| -rw-r--r-- | drive/print.go | 2 | ||||
| -rw-r--r-- | drive/types.go | 2 | ||||
| -rw-r--r-- | gdrive.go | 7 | ||||
| -rw-r--r-- | handlers.go | 1 | 
5 files changed, 12 insertions, 1 deletions
| diff --git a/drive/files.go b/drive/files.go index b10f2f6..6d66234 100644 --- a/drive/files.go +++ b/drive/files.go @@ -16,6 +16,7 @@ func (self *Drive) List(args ListFilesArgs) {      PrintFileList(PrintFileListArgs{          Files: fileList.Files, +        NameWidth: int(args.NameWidth),          SkipHeader: args.SkipHeader,          SizeInBytes: args.SizeInBytes,      }) diff --git a/drive/print.go b/drive/print.go index 85d51b4..eaabae3 100644 --- a/drive/print.go +++ b/drive/print.go @@ -22,7 +22,7 @@ func PrintFileList(args PrintFileListArgs) {      for _, f := range args.Files {          fmt.Fprintf(w, "%s\t%s\t%s\t%s\n",              f.Id, -            truncateString(f.Name, 40), +            truncateString(f.Name, args.NameWidth),              formatSize(f.Size, args.SizeInBytes),              formatDatetime(f.CreatedTime),          ) diff --git a/drive/types.go b/drive/types.go index 296902c..d3f0969 100644 --- a/drive/types.go +++ b/drive/types.go @@ -24,6 +24,7 @@ func NewDrive(client Client) *Drive {  type ListFilesArgs struct {      MaxFiles int64 +    NameWidth int64      Query string      SkipHeader bool      SizeInBytes bool @@ -53,6 +54,7 @@ type FileInfoArgs struct {  type PrintFileListArgs struct {      Files []*drive.File +    NameWidth int      SkipHeader bool      SizeInBytes bool  } @@ -13,6 +13,7 @@ const ClientId     = "367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleu  const ClientSecret = "1qsNodXNaWq1mQuBjUjmvhoO"  const DefaultMaxFiles = 30 +const DefaultNameWidth = 40  const DefaultQuery = "trashed = false and 'me' in owners"  var DefaultConfigDir = GetDefaultConfigDir() @@ -49,6 +50,12 @@ func main() {                          Description: fmt.Sprintf(`Default query: "%s". See https://developers.google.com/drive/search-parameters`, DefaultQuery),                          DefaultValue: DefaultQuery,                      }, +                    cli.IntFlag{ +                        Name: "nameWidth", +                        Patterns: []string{"--name-width"}, +                        Description: fmt.Sprintf("Width of name column, default: %d, minimum: 9, use 0 for full width", DefaultNameWidth), +                        DefaultValue: DefaultNameWidth, +                    },                      cli.BoolFlag{                          Name: "skipHeader",                          Patterns: []string{"--no-header"}, diff --git a/handlers.go b/handlers.go index f681a2d..59607da 100644 --- a/handlers.go +++ b/handlers.go @@ -14,6 +14,7 @@ func listHandler(ctx cli.Context) {      gdrive.List(drive.ListFilesArgs{          MaxFiles: args.Int64("maxFiles"), +        NameWidth: args.Int64("nameWidth"),          Query: args.String("query"),          SkipHeader: args.Bool("skipHeader"),          SizeInBytes: args.Bool("sizeInBytes"), | 
