func aboutExportHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).AboutExport(drive.AboutExportArgs{ Out: os.Stdout, }) checkErr(err) }
func printCommandPrefixHelp(ctx cli.Context, prefix ...string) { handler := getHandler(ctx.Handlers(), prefix) if handler == nil { ExitF("Command not found") } w := new(tabwriter.Writer) w.Init(os.Stdout, 0, 0, 3, ' ', 0) fmt.Fprintf(w, "%s\n", handler.Description) fmt.Fprintf(w, "%s %s\n", Name, handler.Pattern) for _, group := range handler.FlagGroups { fmt.Fprintf(w, "\n%s:\n", group.Name) for _, flag := range group.Flags { boolFlag, isBool := flag.(cli.BoolFlag) if isBool && boolFlag.OmitValue { fmt.Fprintf(w, " %s\t%s\n", strings.Join(flag.GetPatterns(), ", "), flag.GetDescription()) } else { fmt.Fprintf(w, " %s <%s>\t%s\n", strings.Join(flag.GetPatterns(), ", "), flag.GetName(), flag.GetDescription()) } } } w.Flush() }
func listSyncHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).ListSync(drive.ListSyncArgs{ Out: os.Stdout, SkipHeader: args.Bool("skipHeader"), }) checkErr(err) }
func aboutHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).About(drive.AboutArgs{ Out: os.Stdout, SizeInBytes: args.Bool("sizeInBytes"), }) checkErr(err) }
func shareListHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).ListPermissions(drive.ListPermissionsArgs{ Out: os.Stdout, FileId: args.String("fileId"), }) checkErr(err) }
func infoHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).Info(drive.FileInfoArgs{ Out: os.Stdout, Id: args.String("fileId"), SizeInBytes: args.Bool("sizeInBytes"), }) checkErr(err) }
func deleteHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).Delete(drive.DeleteArgs{ Out: os.Stdout, Id: args.String("fileId"), Recursive: args.Bool("recursive"), }) checkErr(err) }
func shareRevokeHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).RevokePermission(drive.RevokePermissionArgs{ Out: os.Stdout, FileId: args.String("fileId"), PermissionId: args.String("permissionId"), }) checkErr(err) }
func mkdirHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).Mkdir(drive.MkdirArgs{ Out: os.Stdout, Name: args.String("name"), Parents: args.StringSlice("parent"), }) checkErr(err) }
func deleteRevisionHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).DeleteRevision(drive.DeleteRevisionArgs{ Out: os.Stdout, FileId: args.String("fileId"), RevisionId: args.String("revId"), }) checkErr(err) }
func importHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).Import(drive.ImportArgs{ Out: os.Stdout, Path: args.String("path"), Parents: args.StringSlice("parent"), Progress: progressWriter(args.Bool("noProgress")), }) checkErr(err) }
func exportHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).Export(drive.ExportArgs{ Out: os.Stdout, Id: args.String("fileId"), Mime: args.String("mime"), PrintMimes: args.Bool("printMimes"), Force: args.Bool("force"), }) checkErr(err) }
func listRevisionsHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).ListRevisions(drive.ListRevisionsArgs{ Out: os.Stdout, Id: args.String("fileId"), NameWidth: args.Int64("nameWidth"), SizeInBytes: args.Bool("sizeInBytes"), SkipHeader: args.Bool("skipHeader"), }) checkErr(err) }
func printHelp(ctx cli.Context) { w := new(tabwriter.Writer) w.Init(os.Stdout, 0, 0, 3, ' ', 0) fmt.Fprintf(w, "%s usage:\n\n", Name) for _, h := range ctx.Handlers() { fmt.Fprintf(w, "%s %s\t%s\n", Name, h.Pattern, h.Description) } w.Flush() }
func downloadQueryHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).DownloadQuery(drive.DownloadQueryArgs{ Out: os.Stdout, Query: args.String("query"), Force: args.Bool("force"), Recursive: args.Bool("recursive"), Path: args.String("path"), Progress: progressWriter(args.Bool("noProgress")), }) checkErr(err) }
func listChangesHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).ListChanges(drive.ListChangesArgs{ Out: os.Stdout, PageToken: args.String("pageToken"), MaxChanges: args.Int64("maxChanges"), Now: args.Bool("now"), NameWidth: args.Int64("nameWidth"), SkipHeader: args.Bool("skipHeader"), }) checkErr(err) }
func listRecursiveSyncHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).ListRecursiveSync(drive.ListRecursiveSyncArgs{ Out: os.Stdout, RootId: args.String("fileId"), SkipHeader: args.Bool("skipHeader"), PathWidth: args.Int64("pathWidth"), SizeInBytes: args.Bool("sizeInBytes"), SortOrder: args.String("sortOrder"), }) checkErr(err) }
func shareHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).Share(drive.ShareArgs{ Out: os.Stdout, FileId: args.String("fileId"), Role: args.String("role"), Type: args.String("type"), Email: args.String("email"), Discoverable: args.Bool("discoverable"), }) checkErr(err) }
func downloadRevisionHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).DownloadRevision(drive.DownloadRevisionArgs{ Out: os.Stdout, FileId: args.String("fileId"), RevisionId: args.String("revId"), Force: args.Bool("force"), Stdout: args.Bool("stdout"), Path: args.String("path"), Progress: progressWriter(args.Bool("noProgress")), Timeout: durationInSeconds(args.Int64("timeout")), }) checkErr(err) }
func listHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).List(drive.ListFilesArgs{ Out: os.Stdout, MaxFiles: args.Int64("maxFiles"), NameWidth: args.Int64("nameWidth"), Query: args.String("query"), SortOrder: args.String("sortOrder"), SkipHeader: args.Bool("skipHeader"), SizeInBytes: args.Bool("sizeInBytes"), AbsPath: args.Bool("absPath"), }) checkErr(err) }
func uploadStdinHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).UploadStream(drive.UploadStreamArgs{ Out: os.Stdout, In: os.Stdin, Name: args.String("name"), Parents: args.StringSlice("parent"), Mime: args.String("mime"), Share: args.Bool("share"), ChunkSize: args.Int64("chunksize"), Timeout: durationInSeconds(args.Int64("timeout")), Progress: progressWriter(args.Bool("noProgress")), }) checkErr(err) }
func updateHandler(ctx cli.Context) { args := ctx.Args() err := newDrive(args).Update(drive.UpdateArgs{ Out: os.Stdout, Id: args.String("fileId"), Path: args.String("path"), Name: args.String("name"), Parents: args.StringSlice("parent"), Mime: args.String("mime"), Progress: progressWriter(args.Bool("noProgress")), ChunkSize: args.Int64("chunksize"), Timeout: durationInSeconds(args.Int64("timeout")), }) checkErr(err) }
func downloadSyncHandler(ctx cli.Context) { args := ctx.Args() cachePath := filepath.Join(args.String("configDir"), DefaultCacheFileName) err := newDrive(args).DownloadSync(drive.DownloadSyncArgs{ Out: os.Stdout, Progress: progressWriter(args.Bool("noProgress")), Path: args.String("path"), RootId: args.String("fileId"), DryRun: args.Bool("dryRun"), DeleteExtraneous: args.Bool("deleteExtraneous"), Timeout: durationInSeconds(args.Int64("timeout")), Resolution: conflictResolution(args), Comparer: NewCachedMd5Comparer(cachePath), }) checkErr(err) }
func downloadHandler(ctx cli.Context) { args := ctx.Args() checkDownloadArgs(args) err := newDrive(args).Download(drive.DownloadArgs{ Out: os.Stdout, Id: args.String("fileId"), Force: args.Bool("force"), Skip: args.Bool("skip"), Path: args.String("path"), Delete: args.Bool("delete"), Recursive: args.Bool("recursive"), Stdout: args.Bool("stdout"), Progress: progressWriter(args.Bool("noProgress")), Timeout: durationInSeconds(args.Int64("timeout")), }) checkErr(err) }
func uploadHandler(ctx cli.Context) { args := ctx.Args() checkUploadArgs(args) err := newDrive(args).Upload(drive.UploadArgs{ Out: os.Stdout, Progress: progressWriter(args.Bool("noProgress")), Path: args.String("path"), Name: args.String("name"), Parents: args.StringSlice("parent"), Mime: args.String("mime"), Recursive: args.Bool("recursive"), Share: args.Bool("share"), Delete: args.Bool("delete"), ChunkSize: args.Int64("chunksize"), Timeout: durationInSeconds(args.Int64("timeout")), }) checkErr(err) }
func printSubCommandHelp(ctx cli.Context) { args := ctx.Args() printCommandPrefixHelp(ctx, args.String("command"), args.String("subcommand")) }