c9ac014473
- Extract shared manifest types into internal/manifest/types leaf package. - Extract SQLite adapter into internal/manifest/sqlite. - Extract JSONL adapter into internal/manifest/jsonl. - Isolate modernc.org/sqlite import to sqlite/adapter.go. - Add adapter-backed registry with manifest.Default. - Adapter-agnostic ConvertManifest in types/. - MemoryAdapter for in-memory manifest testing. - CLI uses manifest.Default registry directly. - SQLite LogWriter type assertion moved into SQLiteAdapter. - Manifest interface includes Entries(); EntryReader removed. - No behavior changes. 100% coverage across all 6 packages.
48 lines
971 B
Go
48 lines
971 B
Go
package manifest
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gitea.k3s.k0.nu/tools/photocli/internal/manifest/types"
|
|
)
|
|
|
|
func Open(dir string, format Format) (Manifest, error) {
|
|
return Default.Open(dir, format)
|
|
}
|
|
|
|
func ConvertFromJSONL(dir string) (Manifest, error) {
|
|
return types.ConvertManifest(dir, JSONLAdapter, SQLiteAdapter)
|
|
}
|
|
|
|
func ConvertFromSQLite(dir string) (Manifest, error) {
|
|
return types.ConvertManifest(dir, SQLiteAdapter, JSONLAdapter)
|
|
}
|
|
|
|
func FileExists(path string) bool {
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return !info.IsDir()
|
|
}
|
|
|
|
func ParseFormat(s string) (Format, error) {
|
|
return Default.ParseFormat(s)
|
|
}
|
|
|
|
func OpenLogWriter(m Manifest, dir string) (LogWriter, error) {
|
|
format := FormatJSONL
|
|
if reporter, ok := m.(types.FormatReporter); ok {
|
|
format = reporter.ManifestFormat()
|
|
}
|
|
return Default.OpenLogWriter(m, dir, format)
|
|
}
|
|
|
|
func osRemove(path string) error {
|
|
return os.Remove(path)
|
|
}
|
|
|
|
func init() {
|
|
types.SetRemoveFunc(osRemove)
|
|
}
|