Documentation
¶
Overview ¶
Package client provides the etu journal backend client: configuration, caching, and gRPC calls used by the CLI and TUI.
Index ¶
- func CachePath(filename string) (string, error)
- func ConfigDir() (string, error)
- func ConfigPath() (string, error)
- func LoadAudioUploads(paths []string) ([]*proto.AudioUpload, error)
- func LoadImageUploads(paths []string) ([]*proto.ImageUpload, error)
- type Config
- func (c *Config) DeletePost(ctx context.Context, pageID string) error
- func (c *Config) GetPostFullContent(ctx context.Context, pageID string) (string, error)
- func (c *Config) GetRandomPosts(ctx context.Context, count int) ([]*Post, error)
- func (c *Config) GetStats(ctx context.Context, global bool) (Stats, error)
- func (c *Config) ListPosts(ctx context.Context, count int) ([]*Post, error)
- func (c *Config) ListTags(ctx context.Context) ([]Tag, error)
- func (c *Config) SaveEntry(ctx context.Context, text string, imagePaths, audioPaths []string) error
- func (c *Config) SearchPosts(ctx context.Context, query string, maxResults int) ([]*Post, error)
- func (c *Config) TimeSinceLastPost(ctx context.Context) (time.Duration, error)
- func (c *Config) UpdateCache(ctx context.Context) error
- func (c *Config) UpdatePost(ctx context.Context, pageID, content string) (*Post, error)
- func (c *Config) Validate() error
- type ConfigFile
- type Post
- type Stats
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CachePath ¶ added in v1.3.0
CachePath returns the path for a cache file under the config directory. Example: CachePath("timesince.cache") => ~/.config/etu/timesince.cache
func ConfigDir ¶ added in v1.3.0
ConfigDir returns the etu config directory (e.g. ~/.config/etu on Unix). Creates the directory if it does not exist. Use this for config and cache files.
func ConfigPath ¶ added in v1.3.0
ConfigPath returns the path to the config file (~/.config/etu/config.json).
func LoadAudioUploads ¶ added in v1.3.0
func LoadAudioUploads(paths []string) ([]*proto.AudioUpload, error)
LoadAudioUploads reads audio files from paths and returns proto AudioUpload messages. MIME type is detected from content (or file extension as fallback).
func LoadImageUploads ¶ added in v1.3.0
func LoadImageUploads(paths []string) ([]*proto.ImageUpload, error)
LoadImageUploads reads image files from paths and returns proto ImageUpload messages. MIME type is detected from content (or file extension as fallback).
Types ¶
type Config ¶ added in v0.1.0
Config holds the configuration for the client.
func LoadConfig ¶ added in v1.1.2
func LoadConfig() *Config
LoadConfig loads configuration from ~/.config/etu/config.json and environment variables. Env ETU_API_KEY and ETU_GRPC_TARGET override file values. If no config file exists and no API key is set, a config file is created with the correct structure and an empty key.
func (*Config) DeletePost ¶ added in v0.1.0
DeletePost deletes a journal entry by ID.
func (*Config) GetPostFullContent ¶ added in v0.1.0
GetPostFullContent fetches the full content of a post by ID.
func (*Config) GetRandomPosts ¶ added in v1.4.0
GetRandomPosts fetches random journal entries from the backend.
func (*Config) GetStats ¶ added in v1.5.0
GetStats fetches aggregate stats. When global is true, community-wide stats are returned; otherwise stats are scoped to the current user.
func (*Config) SaveEntry ¶ added in v0.1.0
SaveEntry saves a new journal entry via the backend (tags are generated on the backend). imagePaths and audioPaths are optional paths to image and audio files to attach to the note.
func (*Config) SearchPosts ¶ added in v0.1.0
SearchPosts searches journal entries via the backend.
func (*Config) TimeSinceLastPost ¶ added in v0.1.0
TimeSinceLastPost returns the time since the last post was created.
func (*Config) UpdateCache ¶ added in v0.1.0
UpdateCache updates the cache with the latest post.
func (*Config) UpdatePost ¶ added in v1.5.0
UpdatePost updates the content of an existing journal entry by ID. Tags are left untouched (the backend keeps the existing tag list).
type ConfigFile ¶ added in v1.3.0
ConfigFile represents the persisted config file format.
func SaveConfig ¶ added in v1.3.0
func SaveConfig(apiKey, grpcTarget string) (*ConfigFile, error)
SaveConfig writes api_key and grpc_target to ~/.config/etu/config.json. Creates the config directory if it does not exist.
type Post ¶
type Post struct {
PageID string // Note ID for fetching full content
Tags []string
Text string
CreatedAt time.Time
Images []*proto.NoteImage
Audios []*proto.NoteAudio
}
Post represents a journal entry (display model for TUI/CLI).