Skip to content

Commit

Permalink
Adapt to new generators.
Browse files Browse the repository at this point in the history
  • Loading branch information
Diwaker Gupta committed Mar 14, 2016
1 parent b8bd34a commit a22a5f2
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 38 deletions.
8 changes: 2 additions & 6 deletions cmd/add-member.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ func addMember(cmd *cobra.Command, args []string) (err error) {
email := args[0]
firstName := args[1]
lastName := args[2]
arg := team.NewMembersAddArg()
member := team.NewMemberAddArg()
member.MemberEmail = email
member.MemberGivenName = firstName
member.MemberSurname = lastName
arg.NewMembers = append(arg.NewMembers, member)
member := team.NewMemberAddArg(email, firstName, lastName)
arg := team.NewMembersAddArg([]*team.MemberAddArg{member})
res, err := dbx.MembersAdd(arg)
if err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func get(cmd *cobra.Command, args []string) (err error) {
dst = path.Base(src)
}

arg := files.NewDownloadArg()
arg.Path = src
arg := files.NewDownloadArg(src)

res, contents, err := dbx.Download(arg)
defer contents.Close()
Expand Down
6 changes: 2 additions & 4 deletions cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ func ls(cmd *cobra.Command, args []string) (err error) {
}
}

arg := files.NewListFolderArg()
arg.Path = path
arg := files.NewListFolderArg(path)

res, err := dbx.ListFolder(arg)
if err != nil {
Expand All @@ -57,8 +56,7 @@ func ls(cmd *cobra.Command, args []string) (err error) {
entries := res.Entries

for res.HasMore {
arg := files.NewListFolderContinueArg()
arg.Cursor = res.Cursor
arg := files.NewListFolderContinueArg(res.Cursor)

res, err = dbx.ListFolderContinue(arg)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ func mkdir(cmd *cobra.Command, args []string) (err error) {
return
}

arg := files.NewCreateFolderArg()
arg.Path = dst
arg := files.NewCreateFolderArg(dst)

if _, err = dbx.CreateFolder(arg); err != nil {
return
Expand Down
14 changes: 4 additions & 10 deletions cmd/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ func uploadChunked(r io.Reader, commitInfo *files.CommitInfo, sizeTotal int64) (
written := chunkSize

for (sizeTotal - written) > chunkSize {
args := files.NewUploadSessionCursor()
args.SessionId = res.SessionId
args.Offset = uint64(written)
args := files.NewUploadSessionCursor(res.SessionId, uint64(written))

err = dbx.UploadSessionAppend(args, &io.LimitedReader{R: r, N: chunkSize})
if err != nil {
Expand All @@ -46,11 +44,8 @@ func uploadChunked(r io.Reader, commitInfo *files.CommitInfo, sizeTotal int64) (
written += chunkSize
}

args := files.NewUploadSessionFinishArg()
args.Cursor = files.NewUploadSessionCursor()
args.Cursor.SessionId = res.SessionId
args.Cursor.Offset = uint64(written)
args.Commit = commitInfo
cursor := files.NewUploadSessionCursor(res.SessionId, uint64(written))
args := files.NewUploadSessionFinishArg(cursor, commitInfo)

if _, err = dbx.UploadSessionFinish(args, r); err != nil {
return
Expand Down Expand Up @@ -87,8 +82,7 @@ func put(cmd *cobra.Command, args []string) (err error) {
Size: contentsInfo.Size(),
}

commitInfo := files.NewCommitInfo()
commitInfo.Path = dst
commitInfo := files.NewCommitInfo(dst)
commitInfo.Mode.Tag = "overwrite"

if contentsInfo.Size() > chunkSize {
Expand Down
3 changes: 1 addition & 2 deletions cmd/remove-member.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import (

func removeMember(cmd *cobra.Command, args []string) (err error) {
email := args[0]
arg := team.NewMembersRemoveArg()
arg.User = &team.UserSelectorArg{Tag: "email", Email: email}
arg := team.NewMembersRemoveArg(&team.UserSelectorArg{Tag: "email", Email: email})
res, err := dbx.MembersRemove(arg)
if err != nil {
return err
Expand Down
4 changes: 1 addition & 3 deletions cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ func restore(cmd *cobra.Command, args []string) (err error) {

rev := args[1]

arg := files.NewRestoreArg()
arg.Path = path
arg.Rev = rev
arg := files.NewRestoreArg(path, rev)

if _, err = dbx.Restore(arg); err != nil {
return
Expand Down
3 changes: 1 addition & 2 deletions cmd/revs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ func revs(cmd *cobra.Command, args []string) (err error) {
return
}

arg := files.NewListRevisionsArg()
arg.Path = path
arg := files.NewListRevisionsArg(path)

res, err := dbx.ListRevisions(arg)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ func rm(cmd *cobra.Command, args []string) (err error) {
return
}

arg := files.NewDeleteArg()
arg.Path = path
arg := files.NewDeleteArg(path)

if _, err = dbx.Delete(arg); err != nil {
return
Expand Down
4 changes: 1 addition & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ func makeRelocationArg(s string, d string) (arg *files.RelocationArg, err error)
return
}

arg = files.NewRelocationArg()
arg.FromPath = src
arg.ToPath = dst
arg = files.NewRelocationArg(src, dst)

return
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import (
)

func search(cmd *cobra.Command, args []string) (err error) {
arg := files.NewSearchArg()
arg.Query = args[0]
arg := files.NewSearchArg("", args[0])

res, err := dbx.Search(arg)
if err != nil {
Expand Down

0 comments on commit a22a5f2

Please sign in to comment.