Documentation
¶
Index ¶
- Variables
- func ContentWidth() int
- func ExpandDateRange(start, end string) (string, string, error)
- func ExpandEndDate(dateStr string) (string, error)
- func ExpandStartDate(dateStr string) (string, error)
- func FTS5Available() bool
- func FormatDate() string
- func FormatEntryCompact(entry Entry, id int64, notruncate bool, showJournal bool) string
- func FormatEntryMinimal(entry Entry, id int64, notruncate bool, showJournal bool) string
- func FormatEntryTabular(entry Entry, id int64, notruncate bool, showJournal bool) string
- func FormatFullEntry(entry Entry) string
- func FormatSearchResult(entry Entry, id int64, notruncate bool) string
- func OpenBrowser(url string) error
- func ParseDate(dateStr string) (time.Time, error)
- func SaveConfig(config Config) error
- func SetDefaultJournal(name string) error
- func SetUp(d getUserConfigDir) (string, error)
- func TabularHeader(showJournal bool) string
- type Config
- type DBPathChecker
- type DisplayFormat
- type Entry
- type EntryReader
- type EntryWriter
- type ExportOptions
- type Exporter
- type ImportOptions
- type Journal
- type JournalMetadata
- type JournalRepository
- type Options
- type ParsedEntry
- type SQLiteRepository
- func (r *SQLiteRepository) All() ([]Entry, error)
- func (r *SQLiteRepository) AllWithTags() ([]Entry, error)
- func (r *SQLiteRepository) Create(entry Entry) (*Entry, error)
- func (r *SQLiteRepository) CreateJournal(journal Journal) (*Journal, error)
- func (r *SQLiteRepository) CreateWithTags(entry Entry, tagNames []string) (*Entry, error)
- func (r *SQLiteRepository) Delete(id int64) error
- func (r *SQLiteRepository) DeleteJournal(name string) error
- func (r *SQLiteRepository) DeleteTag(name string) error
- func (r *SQLiteRepository) ExportJournal(opts ExportOptions) error
- func (r *SQLiteRepository) ExportToMarkdown(entries []Entry, w io.Writer) error
- func (r *SQLiteRepository) ExportToMarkdownByDate(entries []Entry, w io.Writer) error
- func (r *SQLiteRepository) ExportToText(entries []Entry, w io.Writer) error
- func (r *SQLiteRepository) FindSimilarTags(name string) ([]Tag, error)
- func (r *SQLiteRepository) GetAllJournalEntries(name string) ([]Entry, error)
- func (r *SQLiteRepository) GetByID(id int64) (*Entry, error)
- func (r *SQLiteRepository) GetByIDWithTags(id int64) (*Entry, error)
- func (r *SQLiteRepository) GetByJournal(journalName string) ([]Entry, error)
- func (r *SQLiteRepository) GetJournalEntryCount(name string) (int, error)
- func (r *SQLiteRepository) GetOrCreateTag(name string) (*Tag, error)
- func (r *SQLiteRepository) GetRecent(limit int, journalName string) ([]Entry, error)
- func (r *SQLiteRepository) GetTagEntries(tagName string) ([]Entry, error)
- func (r *SQLiteRepository) GetTagEntryCount(name string) (int, error)
- func (r *SQLiteRepository) ImportJournal(opts ImportOptions) error
- func (r *SQLiteRepository) JournalExists(name string) (bool, error)
- func (r *SQLiteRepository) ListJournals() ([]Journal, error)
- func (r *SQLiteRepository) ListTags() ([]Tag, error)
- func (r *SQLiteRepository) Migrate() error
- func (r *SQLiteRepository) RenameJournal(oldName, newName string) error
- func (r *SQLiteRepository) RenameTag(oldName, newName string) error
- func (r *SQLiteRepository) Search(query string, journalName string) ([]Entry, error)
- func (r *SQLiteRepository) SearchByDateRange(start, end, journalName string) ([]Entry, error)
- func (r *SQLiteRepository) SearchByDateRangeWithQuery(start, end, query, journalName string) ([]Entry, error)
- func (r *SQLiteRepository) TagExists(name string) (bool, error)
- func (r *SQLiteRepository) Update(id int64, updated Entry) (*Entry, error)
- func (r *SQLiteRepository) UpdateWithTags(id int64, entry Entry, tagNames []string) (*Entry, error)
- type Searcher
- type SyncthingConfig
- type Tag
- type TagRepository
Constants ¶
This section is empty.
Variables ¶
var ( IDColor = color.New(color.Bold, color.FgCyan) DateColor = color.New(color.Faint) TagColor = color.New(color.FgYellow) URLColor = color.New(color.Bold, color.FgMagenta) HeaderColor = color.New(color.Bold) DimColor = color.New(color.Faint) )
Display colors (package-level, can be disabled via NO_COLOR).
Functions ¶
func ContentWidth ¶
func ContentWidth() int
ContentWidth calculates the available width for content based on terminal width. This function is deprecated in favor of inline calculations in format functions.
func ExpandEndDate ¶
ExpandEndDate expands a partial date to the end of that period. E.g., "2025-12" becomes "2025-12-31T23:59:59".
func ExpandStartDate ¶
ExpandStartDate expands a partial date to the start of that period. E.g., "2025-12" becomes "2025-12-01T00:00:00".
func FTS5Available ¶
func FTS5Available() bool
FTS5Available returns whether FTS5 full-text search is available.
func FormatDate ¶
func FormatDate() string
FormatDate returns the current time formatted for entry timestamps.
func FormatEntryCompact ¶
FormatEntryCompact formats an entry in git-style compact format. Tags appear inline at the end of the content.
func FormatEntryMinimal ¶
FormatEntryMinimal formats an entry with tags at the end of the line.
func FormatEntryTabular ¶
FormatEntryTabular formats an entry with aligned columns.
func FormatFullEntry ¶
FormatFullEntry formats a complete entry for detailed display. Note: For encrypted entries, the caller should decrypt the content first before calling this function, or the raw encrypted content will be shown.
func FormatSearchResult ¶
FormatSearchResult formats an entry for display in search/list results. Defaults to tabular format for backward compatibility.
func OpenBrowser ¶
OpenBrowser opens the given URL in the system's default browser.
func SaveConfig ¶
func SetDefaultJournal ¶
func TabularHeader ¶
TabularHeader returns the header row for tabular format.
Types ¶
type Config ¶
type Config struct {
DefaultJournal string `json:"default_journal"`
DateFormat string `json:"date_format"`
DefaultExportFormat string `json:"default_export_format"`
Syncthing *SyncthingConfig `json:"syncthing,omitempty"`
}
Config holds user configuration settings.
func LoadConfig ¶
type DBPathChecker ¶
type DBPathChecker struct {
// contains filtered or unexported fields
}
DBPathChecker contains the func used to create the user config dir.
func NewDBPathChecker ¶
func NewDBPathChecker(f getUserConfigDir) *DBPathChecker
NewDBPathChecker creates a DBPathChecker using the provided config dir function.
func (*DBPathChecker) Check ¶
func (db *DBPathChecker) Check() bool
Check returns true if the database file exists, false otherwise.
type DisplayFormat ¶
type DisplayFormat int
DisplayFormat represents the output format style.
const ( FormatTabular DisplayFormat = iota // Default: aligned columns FormatCompact // Git-style, tags inline with content FormatMinimal // Tags at end of line )
func ParseDisplayFormat ¶
func ParseDisplayFormat(s string) DisplayFormat
ParseDisplayFormat converts a string to DisplayFormat.
type Entry ¶
type Entry struct {
ID int64
Time string
Content string
URL *string
Journal int64
JournalName string
Tags []Tag
Encrypted bool
}
Entry represents a journal entry.
type EntryReader ¶
type EntryReader interface {
GetByID(id int64) (*Entry, error)
GetByIDWithTags(id int64) (*Entry, error)
GetByJournal(journalName string) ([]Entry, error)
GetRecent(limit int, journalName string) ([]Entry, error)
AllWithTags() ([]Entry, error)
}
EntryReader provides read operations for entries.
type EntryWriter ¶
type EntryWriter interface {
CreateWithTags(entry Entry, tagNames []string) (*Entry, error)
Update(id int64, updated Entry) (*Entry, error)
UpdateWithTags(id int64, entry Entry, tagNames []string) (*Entry, error)
Delete(id int64) error
}
EntryWriter provides write operations for entries.
type ExportOptions ¶
type ExportOptions struct {
JournalName string
OutputPath string
Encrypt bool
Passphrase string
RemoveAfterExport bool
DryRun bool
}
ExportOptions configures journal archive export.
func (ExportOptions) GetFinalOutputPath ¶
func (opts ExportOptions) GetFinalOutputPath() string
GetFinalOutputPath returns the final output path for an export.
type Exporter ¶
type Exporter interface {
ExportToMarkdown(entries []Entry, w io.Writer) error
ExportToMarkdownByDate(entries []Entry, w io.Writer) error
ExportToText(entries []Entry, w io.Writer) error
ExportJournal(opts ExportOptions) error
ImportJournal(opts ImportOptions) error
}
Exporter provides export operations for entries.
type ImportOptions ¶
ImportOptions configures journal archive import.
type JournalMetadata ¶
type JournalMetadata struct {
JournalName string `json:"journal_name"`
ExportDate string `json:"export_date"`
EntryCount int `json:"entry_count"`
Version string `json:"version"`
}
JournalMetadata holds metadata for exported journal archives.
type JournalRepository ¶
type JournalRepository interface {
CreateJournal(journal Journal) (*Journal, error)
DeleteJournal(name string) error
JournalExists(name string) (bool, error)
GetJournalEntryCount(name string) (int, error)
GetAllJournalEntries(name string) ([]Entry, error)
ListJournals() ([]Journal, error)
RenameJournal(oldName, newName string) error
}
JournalRepository provides operations for managing journals.
type ParsedEntry ¶
ParsedEntry represents an entry parsed from markdown during import.
type SQLiteRepository ¶
type SQLiteRepository struct {
// contains filtered or unexported fields
}
SQLiteRepository implements repository operations using SQLite.
func NewSQLiteRepository ¶
func NewSQLiteRepository(db *sql.DB) *SQLiteRepository
NewSQLiteRepository creates a new SQLite-backed repository.
func (*SQLiteRepository) All ¶
func (r *SQLiteRepository) All() ([]Entry, error)
All returns all entries without tags (used by tests).
func (*SQLiteRepository) AllWithTags ¶
func (r *SQLiteRepository) AllWithTags() ([]Entry, error)
func (*SQLiteRepository) Create ¶
func (r *SQLiteRepository) Create(entry Entry) (*Entry, error)
Create inserts a new entry without tags (used by tests).
func (*SQLiteRepository) CreateJournal ¶
func (r *SQLiteRepository) CreateJournal(journal Journal) (*Journal, error)
func (*SQLiteRepository) CreateWithTags ¶
func (r *SQLiteRepository) CreateWithTags(entry Entry, tagNames []string) (*Entry, error)
func (*SQLiteRepository) Delete ¶
func (r *SQLiteRepository) Delete(id int64) error
func (*SQLiteRepository) DeleteJournal ¶
func (r *SQLiteRepository) DeleteJournal(name string) error
func (*SQLiteRepository) DeleteTag ¶
func (r *SQLiteRepository) DeleteTag(name string) error
func (*SQLiteRepository) ExportJournal ¶
func (r *SQLiteRepository) ExportJournal(opts ExportOptions) error
func (*SQLiteRepository) ExportToMarkdown ¶
func (r *SQLiteRepository) ExportToMarkdown(entries []Entry, w io.Writer) error
func (*SQLiteRepository) ExportToMarkdownByDate ¶
func (r *SQLiteRepository) ExportToMarkdownByDate(entries []Entry, w io.Writer) error
func (*SQLiteRepository) ExportToText ¶
func (r *SQLiteRepository) ExportToText(entries []Entry, w io.Writer) error
func (*SQLiteRepository) FindSimilarTags ¶
func (r *SQLiteRepository) FindSimilarTags(name string) ([]Tag, error)
func (*SQLiteRepository) GetAllJournalEntries ¶
func (r *SQLiteRepository) GetAllJournalEntries(name string) ([]Entry, error)
func (*SQLiteRepository) GetByIDWithTags ¶
func (r *SQLiteRepository) GetByIDWithTags(id int64) (*Entry, error)
func (*SQLiteRepository) GetByJournal ¶
func (r *SQLiteRepository) GetByJournal(journalName string) ([]Entry, error)
func (*SQLiteRepository) GetJournalEntryCount ¶
func (r *SQLiteRepository) GetJournalEntryCount(name string) (int, error)
func (*SQLiteRepository) GetOrCreateTag ¶
func (r *SQLiteRepository) GetOrCreateTag(name string) (*Tag, error)
func (*SQLiteRepository) GetRecent ¶
func (r *SQLiteRepository) GetRecent(limit int, journalName string) ([]Entry, error)
func (*SQLiteRepository) GetTagEntries ¶
func (r *SQLiteRepository) GetTagEntries(tagName string) ([]Entry, error)
func (*SQLiteRepository) GetTagEntryCount ¶
func (r *SQLiteRepository) GetTagEntryCount(name string) (int, error)
func (*SQLiteRepository) ImportJournal ¶
func (r *SQLiteRepository) ImportJournal(opts ImportOptions) error
func (*SQLiteRepository) JournalExists ¶
func (r *SQLiteRepository) JournalExists(name string) (bool, error)
func (*SQLiteRepository) ListJournals ¶
func (r *SQLiteRepository) ListJournals() ([]Journal, error)
ListJournals returns all journals ordered by name.
func (*SQLiteRepository) ListTags ¶
func (r *SQLiteRepository) ListTags() ([]Tag, error)
func (*SQLiteRepository) Migrate ¶
func (r *SQLiteRepository) Migrate() error
Migrate creates database tables and runs schema migrations.
func (*SQLiteRepository) RenameJournal ¶
func (r *SQLiteRepository) RenameJournal(oldName, newName string) error
func (*SQLiteRepository) RenameTag ¶
func (r *SQLiteRepository) RenameTag(oldName, newName string) error
func (*SQLiteRepository) Search ¶
func (r *SQLiteRepository) Search(query string, journalName string) ([]Entry, error)
func (*SQLiteRepository) SearchByDateRange ¶
func (r *SQLiteRepository) SearchByDateRange(start, end, journalName string) ([]Entry, error)
func (*SQLiteRepository) SearchByDateRangeWithQuery ¶
func (r *SQLiteRepository) SearchByDateRangeWithQuery(start, end, query, journalName string) ([]Entry, error)
func (*SQLiteRepository) TagExists ¶
func (r *SQLiteRepository) TagExists(name string) (bool, error)
func (*SQLiteRepository) Update ¶
func (r *SQLiteRepository) Update(id int64, updated Entry) (*Entry, error)
func (*SQLiteRepository) UpdateWithTags ¶
type Searcher ¶
type Searcher interface {
Search(query string, journalName string) ([]Entry, error)
SearchByDateRange(start, end, journalName string) ([]Entry, error)
SearchByDateRangeWithQuery(start, end, query, journalName string) ([]Entry, error)
}
Searcher provides search operations for entries.
type SyncthingConfig ¶
type SyncthingConfig struct {
Enabled bool `json:"enabled"`
APIURL string `json:"api_url"`
APIKey string `json:"api_key"`
FolderID string `json:"folder_id"`
FilePath string `json:"file_path"`
}
SyncthingConfig holds Syncthing integration settings for sync safety.
type TagRepository ¶
type TagRepository interface {
GetOrCreateTag(name string) (*Tag, error)
FindSimilarTags(name string) ([]Tag, error)
ListTags() ([]Tag, error)
GetTagEntries(tagName string) ([]Entry, error)
RenameTag(oldName, newName string) error
DeleteTag(name string) error
}
TagRepository provides operations for managing tags.