Documentation
¶
Index ¶
- Constants
- Variables
- func AddMdSuffix(str string) string
- func GenerateBacklinkSearchPatterns(notePath string) []string
- func GenerateLinkReplacements(oldNotePath, newNotePath string) map[string]string
- func GenerateNoteLinkTexts(noteName string) [3]string
- func ListEntries(vaultPath, relativePath string) ([]string, error)
- func OpenInEditor(filePath string) error
- func RemoveMdSuffix(str string) string
- func ReplaceContent(content []byte, replacements map[string]string) []byte
- func ShouldSkipDirectoryOrFile(info os.FileInfo) bool
- func ValidatePath(basePath, relativePath string) (string, error)
- type CliConfig
- type FuzzyFinder
- type FuzzyFinderManager
- type Note
- func (m *Note) Delete(path string) error
- func (m *Note) FindBacklinks(vaultPath, noteName string) ([]NoteMatch, error)
- func (m *Note) GetContents(vaultPath string, noteName string) (string, error)
- func (m *Note) GetNotesList(vaultPath string) ([]string, error)
- func (m *Note) Move(originalPath string, newPath string) error
- func (m *Note) SearchNotesWithSnippets(vaultPath string, query string) ([]NoteMatch, error)
- func (m *Note) SetContents(vaultPath string, noteName string, content string) error
- func (m *Note) UpdateLinks(vaultPath string, oldNoteName string, newNoteName string) error
- type NoteManager
- type NoteMatch
- type ObsidianVaultConfig
- type Uri
- type UriManager
- type Vault
- type VaultManager
Constants ¶
const ( ExecuteUriError = "Failed to execute Obsidian URI" NoteDoesNotExistError = "Cannot find note in vault" VaultAccessError = "Failed to access vault directory" VaultReadError = "Failed to read notes in vault" VaultWriteError = "Failed to write to update notes in vault" ObsidianCLIConfigReadError = "Cannot find vault config, please use set-default command to set default vault or use --vault flag" ObsidianCLIConfigParseError = "Could not parse vault config file, please use set-default command to set default vault or use --vault flag" ObsidianCLIConfigDirWriteEror = "Failed to create vault config directory. Please ensure you have the correct permissions." ObsidianCLIConfigGenerateJSONError = "Failed to generate vault config file. Please ensure vault name does not contain any special characters." ObsidianCLIConfigWriteError = "Failed to write vault config file. Please ensure you have correct permissions." ObsidianConfigReadError = "Failed to read Obsidian config file. Please ensure vault has been set up in Obsidian." ObsidianConfigParseError = "Failed to parse Obsidian config file. Please ensure vault has been set up in Obsidian." ObsidianConfigVaultNotFoundError = "Vault not found in Obsidian config file. Please ensure vault has been set up in Obsidian." )
Variables ¶
var CliConfigPath = config.CliPath
var ErrPathTraversal = errors.New("path traversal detected: path must remain within vault directory")
ErrPathTraversal is returned when a path attempts to escape the base directory
var JsonMarshal = json.Marshal
var ObsidianConfigFile = config.ObsidianFile
var Run = open.Run
Functions ¶
func AddMdSuffix ¶
func GenerateBacklinkSearchPatterns ¶
GenerateBacklinkSearchPatterns creates patterns to find links pointing to a note.
func GenerateLinkReplacements ¶
GenerateLinkReplacements creates all replacement patterns for updating links when moving a note. It normalizes path separators to forward slashes for cross-platform consistency, as Obsidian uses forward slashes in links regardless of operating system. This handles: - Simple wikilinks: [[note]], [[note|alias]], [[note#heading]] - Path-based wikilinks: [folder/note], [[folder/note|alias]], [[folder/note#heading]] - Markdown links: [text](folder/note.md), [text](./folder/note.md)
func GenerateNoteLinkTexts ¶
func ListEntries ¶
func OpenInEditor ¶
OpenInEditor opens the specified file path in the user's preferred editor It supports common GUI editors with appropriate wait flags
func RemoveMdSuffix ¶
func ValidatePath ¶
ValidatePath ensures the given relative path, when combined with basePath, stays within basePath. It returns the cleaned absolute path on success.
This function: 1. Rejects absolute paths 2. Cleans both paths and joins them 3. Verifies the result starts with the base path
Returns: - The validated absolute path - ErrPathTraversal if path escapes basePath - Other errors for filesystem issues
Types ¶
type FuzzyFinder ¶
type FuzzyFinder struct{}
type FuzzyFinderManager ¶
type Note ¶
type Note struct {
}
func (*Note) FindBacklinks ¶
func (*Note) GetContents ¶
func (*Note) SearchNotesWithSnippets ¶
func (*Note) SetContents ¶
type NoteManager ¶
type NoteManager interface {
Move(string, string) error
Delete(string) error
UpdateLinks(string, string, string) error
GetContents(string, string) (string, error)
SetContents(string, string, string) error
GetNotesList(string) ([]string, error)
SearchNotesWithSnippets(string, string) ([]NoteMatch, error)
FindBacklinks(string, string) ([]NoteMatch, error)
}
type ObsidianVaultConfig ¶
type UriManager ¶
type Vault ¶
type Vault struct {
Name string
}