Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoValue = errors.New("no text to replace")
Functions ¶
func Process ¶
Process replaces a text in the content of every live note of the account, through patchnote in one transaction: the locked notes are skipped and counted, and each note changed keeps a version of its text before. TODO: every note goes through patchnote within the 30 s of a request, fine for a few thousand changed; a job if more.
Types ¶
type Input ¶
type Input struct {
Find string `json:"find"`
Replace string `json:"replace"`
DryRun bool `json:"dry_run,omitempty" binding:"optional"`
Folder string `json:"folder,omitempty" binding:"optional"` // a folder id: only its notes, its subfolders included
Notes []string `json:"notes,omitempty" binding:"optional"` // note ids: only these notes
Occurrence int `json:"occurrence,omitempty" binding:"optional"` // with Notes: only that occurrence of each, from 1
}
Input is a plain text, no regex, found with its case. DryRun only counts and lists the occurrences, for the confirmation. Notes and Occurrence narrow it to what the list shows: a note, or one occurrence of it.
type Line ¶ added in v1.17.4
type Line struct {
Line int `json:"line"`
Before string `json:"before"`
After string `json:"after"`
}
Line is an occurrence: its line in the note, from 1, and the text of the line around it.
type Match ¶ added in v1.17.4
type Match struct {
ID string `json:"id"`
Path string `json:"path"`
Occurrences []Line `json:"occurrences"`
}
Match is a note holding the text, with its occurrences in order: their index is the Occurrence of Input.
type Result ¶
type Result struct {
Notes int `json:"notes"`
Occurrences int `json:"occurrences"`
Locked int `json:"locked"`
Matches []Match `json:"matches,omitempty" binding:"optional"`
}
Result counts the notes holding the text and its occurrences in them; the locked notes are left as they are. A dry run lists the occurrences too, the first maxMatches of them.