mirror of
https://github.com/mickael-menu/zk
synced 2024-11-11 07:10:25 +00:00
50855154e2
* Move everything under the internal package. * Better separation between core and adapter packages, for easier unit testing. * Simplify data models. * Support multiple opened notebooks during runtime (useful for the LSP server). * Proper surface API which might be exposed later as a public Go package.
36 lines
706 B
Go
36 lines
706 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mickael-menu/zk/internal/cli"
|
|
)
|
|
|
|
// 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 *cli.Container) error {
|
|
notebook, err := container.CurrentNotebook()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
stats, err := notebook.Index(cmd.Force)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !cmd.Quiet {
|
|
fmt.Println(stats)
|
|
}
|
|
|
|
return nil
|
|
}
|