mirror of
https://github.com/mickael-menu/zk
synced 2024-11-11 07:10:25 +00:00
f5b3102deb
* YAML frontmatter as a JSON object in `notes.metadata` * Print metadata from the YAML frontmatter in `list` output using `{{metadata.<key>}}`, e.g. `{{metadata.description}}`. Keys are normalized to lower case. * Start and end offsets for link snippets. * This could be useful to expand backlinks contexts.
34 lines
668 B
Go
34 lines
668 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// Index indexes the content of all the notes in the notebook.
|
|
type Index struct {
|
|
Force bool `short:"f" help:"Force indexing all the notes."`
|
|
Quiet bool `short:"q" help:"Do not print statistics nor progress."`
|
|
}
|
|
|
|
func (cmd *Index) Help() string {
|
|
return "You usually do not need to run `zk index` manually, as notes are indexed automatically when needed."
|
|
}
|
|
|
|
func (cmd *Index) Run(container *Container) error {
|
|
zk, err := container.OpenZk()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, stats, err := container.Database(zk, cmd.Force)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err == nil && !cmd.Quiet {
|
|
fmt.Println(stats)
|
|
}
|
|
|
|
return err
|
|
}
|