From d74cf52d1e97513ce290400b06a838b3473e3545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Menu?= Date: Sun, 3 Oct 2021 18:36:59 +0200 Subject: [PATCH] List note tags (#85) --- CHANGELOG.md | 4 +- docs/tags.md | 13 ++ go.mod | 33 ++-- go.sum | 74 +++++---- internal/adapter/lsp/server.go | 2 +- internal/adapter/sqlite/collection_dao.go | 49 ++++-- .../adapter/sqlite/collection_dao_test.go | 37 ++++- internal/adapter/sqlite/note_dao_test.go | 2 +- internal/adapter/sqlite/note_index.go | 4 +- .../sqlite/testdata/default/collections.yml | 3 + .../testdata/default/notes_collections.yml | 9 ++ internal/cli/cmd/tag.go | 148 ++++++++++++++++++ internal/core/collection.go | 72 ++++++++- internal/core/collection_format.go | 44 ++++++ internal/core/note_index.go | 2 +- internal/core/note_new_test.go | 2 +- internal/core/notebook.go | 18 ++- main.go | 2 + 18 files changed, 444 insertions(+), 74 deletions(-) create mode 100644 internal/cli/cmd/tag.go create mode 100644 internal/core/collection_format.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e7a7250..a07d76e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. ### Added +* List the tags found in your notebook with `zk tag list`. + * Many options are available to customize the output, including JSON serialization. See `zk tag list --help`. * Support for LSP references to browse the backlinks of the current note, if the caret is not over a link. * New template variables are available when [generating custom Markdown links with `link-format`](docs/note-format.md). * `filename`, `path`, `abs-path` and `rel-path` for many path flavors. @@ -23,13 +25,13 @@ All notable changes to this project will be documented in this file. * A new `{{substring s index length}}` template helper extracts a portion of a given string, e.g.: * `{{substring 'A full quote' 2 4}}` outputs `full` * `{{substring 'A full quote' -5 5}` outputs `quote` -* Allow setting the `--working-dir` and `--notebook-dir` flags before the `zk` subcommand when using aliases, e.g. `zk -W ~/notes my-alias`. ### Fixed * UTF-8 handling in the LSP server. * [#78](https://github.com/mickael-menu/zk/issues/78) Do not exclude notes containing broken links from the index. +* Allow setting the `--working-dir` and `--notebook-dir` flags before the `zk` subcommand when using aliases, e.g. `zk -W ~/notes my-alias`. ## 0.6.0 diff --git a/docs/tags.md b/docs/tags.md index 45b8715..ec3aee7 100644 --- a/docs/tags.md +++ b/docs/tags.md @@ -12,3 +12,16 @@ You can filter your notes by their tags using the `--tags` option, as demonstrat ```sh $ zk list --tag "inbox OR todo, NOT done" ``` + +## Listing tags + +You can list all the tags found in your notebook using `zk tag list`. + +The following variables are available in the templates used when formatting tags, for example with `zk tag list --format