Skip to content

Commit

Permalink
feat: order (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHope committed Jan 6, 2024
1 parent a251fdb commit a95443e
Show file tree
Hide file tree
Showing 43 changed files with 2,569 additions and 288 deletions.
7 changes: 0 additions & 7 deletions armaria.json

This file was deleted.

22 changes: 19 additions & 3 deletions cmd/cli/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ type ListAllCmd struct {
After *string `help:"ID of bookmark/folder to return results after."`
Query *string `help:"Query to search bookmarks/folders by."`
Tag []string `help:"Tag to filter bookmarks/folders by."`
Order armaria.Order `help:"Field results are ordered on: modified/name." enum:"modified,name" default:"modified"`
Order armaria.Order `help:"Field results are ordered on: modified/name/manual." enum:"modified,name,manual" default:"manual"`
Dir armaria.Direction `help:"Direction results are ordered by: asc/desc." enum:"asc,desc" default:"asc"`
First *int64 `help:"The max number of bookmarks/folders to return."`
}
Expand Down Expand Up @@ -278,7 +278,7 @@ type ListBooksCmd struct {
After *string `help:"ID of bookmark to return results after."`
Query *string `help:"Query to search bookmarks by."`
Tag []string `help:"Tag to filter bookmarks by."`
Order armaria.Order `help:"Field results are ordered on: modified/name." enum:"modified,name" default:"modified"`
Order armaria.Order `help:"Field results are ordered on: modified/name/manual." enum:"modified,name,manual" default:"manual"`
Dir armaria.Direction `help:"Direction results are ordered by: asc/desc." enum:"asc,desc" default:"asc"`
First *int64 `help:"The max number of bookmarks to return."`
}
Expand Down Expand Up @@ -346,7 +346,7 @@ type ListFoldersCmd struct {
After *string `help:"ID of folder to return results after."`
Query *string `help:"Query to search folders by."`
Tag []string `help:"Tag to filter folders by."`
Order armaria.Order `help:"Field results are ordered on: modified/name." enum:"modified,name" default:"modified"`
Order armaria.Order `help:"Field results are ordered on: modified/name/manual." enum:"modified,name,manual" default:"manual"`
Dir armaria.Direction `help:"Direction results are ordered by: asc/desc." enum:"asc,desc" default:"asc"`
First *int64 `help:"The max number of folders to return."`
}
Expand Down Expand Up @@ -488,6 +488,8 @@ type UpdateBookCmd struct {
Description *string `help:"New description for this bookmark."`
NoDescription bool `help:"Remove the description."`
URL *string `help:"New URL for this bookmark."`
Before *string `help:"Book to order this bookmark before."`
After *string `help:"Book to order this bookmark after."`

ID string `arg:"" name:"id" help:"ID of the bookmark to update."`
}
Expand Down Expand Up @@ -530,6 +532,12 @@ func (r *UpdateBookCmd) Run(ctx *Context) error {
if r.URL != nil {
options.WithURL(*r.URL)
}
if r.Before != nil {
options.WithOrderBefore(*r.Before)
}
if r.After != nil {
options.WithOrderAfter(*r.After)
}

book, err := armariaapi.UpdateBook(r.ID, options)
if err != nil {
Expand All @@ -551,6 +559,8 @@ type UpdateFolderCmd struct {
Name *string `help:"New name for this folder."`
Folder *string `help:"Folder to move this folder to."`
NoFolder bool `help:"Remove the parent folder."`
Before *string `help:"Book to order this bookmark before."`
After *string `help:"Book to order this bookmark after."`

ID string `arg:"" name:"id" help:"ID of the folder to update."`
}
Expand Down Expand Up @@ -578,6 +588,12 @@ func (r *UpdateFolderCmd) Run(ctx *Context) error {
if r.Name != nil {
options.WithName(*r.Name)
}
if r.Before != nil {
options.WithOrderBefore(*r.Before)
}
if r.After != nil {
options.WithOrderAfter(*r.After)
}

book, err := armariaapi.UpdateFolder(r.ID, options)
if err != nil {
Expand Down
Loading

0 comments on commit a95443e

Please sign in to comment.