zk/cmd/index.go
Mickaël Menu f5b3102deb
Save additional metadata in the database (#7)
* 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.
2021-03-08 21:38:32 +01:00

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
}