Additions to domain/ and workspace/ chron-note packages

This commit is contained in:
2026-03-11 14:03:52 +08:00
parent 8edeb3ac99
commit 34d18e244e
16 changed files with 744 additions and 3 deletions

View File

@@ -0,0 +1,32 @@
package workspace
import (
"fmt"
"os"
"path/filepath"
"git.michelsen.id/phill/chron/chron-note/internal/domain"
)
type Workspace struct {
Root string
Dir string
}
func Open(root string) (*Workspace, error) {
root = filepath.Clean(root)
dir := filepath.Join(root, ".chron", "workspace")
if err := os.MkdirAll(dir, 0o755); err != nil {
return nil, fmt.Errorf("mkdir workspace dir: %w", err)
}
return &Workspace{
Root: root,
Dir: dir,
}, nil
}
func (ws *Workspace) ObjectPath(id domain.ObjectID) string {
return filepath.Join(ws.Dir, id.String())
}