Skip to content

Commit

Permalink
fix mozeidon bookmarks --go-template
Browse files Browse the repository at this point in the history
  • Loading branch information
egovelox committed Jul 12, 2024
1 parent 46f1bee commit e12a56f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ cd mozeidon/cli && go build
### How to use the Mozeidon CLI with ``go-template`` syntax for customized output :

```bash
# get maximum 10 of latest bookmarks, title and url

mozeidon bookmarks -m 10 --go-template '{{range .Items}}{{.Title}} {{.Url}}{{"\n"}}{{end}}'
```

```bash
# get opened tabs, with 📌 icon if pinned

mozeidon tabs get --go-template '{{range .Items}}{{.WindowId}}:{{.Id}} {{.Url}} {{if .Pinned}}📌{{else}}🦊{{end}} {{"\\u001b[38;5;109m"}} {{.Domain}}{{"\\033[0m"}} {{.Title}}{{"\n"}}{{end}}'
```

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/bookmarks/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var BookmarksCmd = &cobra.Command{
return
}
if len(template) > 0 {
app.BookmarksTemplate(template)
app.BookmarksTemplate(template, maximum, chunk)
} else {
app.BookmarksJson(maximum, chunk)
}
Expand Down
4 changes: 3 additions & 1 deletion cli/core/bookmarks-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ package core

import (
"encoding/json"
"fmt"
"log"
"os"
goTemplates "text/template"

"github.com/egovelox/mozeidon/browser/core/models"
)

func (a *App) BookmarksTemplate(template string) {
func (a *App) BookmarksTemplate(template string, max int64, chunkSize int64) {

for response := range a.browser.Send(
models.Command{
Command: "get-bookmarks",
Args: fmt.Sprintf("%d:%d", max, chunkSize),
},
) {

Expand Down
Binary file modified cli/mozeidon
Binary file not shown.

0 comments on commit e12a56f

Please sign in to comment.