mirror of https://github.com/mickael-menu/zk
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
706 B
Go
36 lines
706 B
Go
4 years ago
|
package cmd
|
||
|
|
||
|
import (
|
||
4 years ago
|
"fmt"
|
||
4 years ago
|
|
||
4 years ago
|
"github.com/mickael-menu/zk/internal/cli"
|
||
4 years ago
|
)
|
||
|
|
||
4 years ago
|
// Index indexes the content of all the notes in the notebook.
|
||
4 years ago
|
type Index struct {
|
||
4 years ago
|
Force bool `short:"f" help:"Force indexing all the notes."`
|
||
|
Quiet bool `short:"q" help:"Do not print statistics nor progress."`
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
func (cmd *Index) Help() string {
|
||
4 years ago
|
return "You usually do not need to run `zk index` manually, as notes are indexed automatically when needed."
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
func (cmd *Index) Run(container *cli.Container) error {
|
||
|
notebook, err := container.CurrentNotebook()
|
||
4 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
4 years ago
|
stats, err := notebook.Index(cmd.Force)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
if !cmd.Quiet {
|
||
4 years ago
|
fmt.Println(stats)
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
return nil
|
||
4 years ago
|
}
|