Add initial CLI support
This commit is contained in:
parent
e16d67e2f8
commit
22a9c68611
14 changed files with 168 additions and 26 deletions
|
|
@ -9,9 +9,12 @@ tree serialization respectively.
|
|||
from typing import Optional, Self
|
||||
from pathlib import Path
|
||||
|
||||
from .db import Sqlite3Trove
|
||||
from .db import Sqlite3Trove, NOTE_ROOT_ID
|
||||
from .tree import Tree as TreeData
|
||||
from .trove import NODE_ROOT_ID, Note, Trove, TreeNote, BlobNote, TreeEntry, NoteNotFound
|
||||
|
||||
from . import trove as tr
|
||||
|
||||
from .trove import Note, Trove, TreeNote, BlobNote, TreeEntry, NoteNotFound
|
||||
|
||||
|
||||
class NoteImpl(Note):
|
||||
|
|
@ -131,7 +134,7 @@ class TroveImpl:
|
|||
if create:
|
||||
# Root was written as a blob by Sqlite3Trove.open(); fix its type.
|
||||
db._con.execute(
|
||||
"UPDATE objects SET type = 'tree' WHERE id = ?", (NODE_ROOT_ID,)
|
||||
"UPDATE objects SET type = 'tree' WHERE id = ?", (NOTE_ROOT_ID,)
|
||||
)
|
||||
db._con.commit()
|
||||
return trove
|
||||
|
|
@ -168,7 +171,7 @@ class TroveImpl:
|
|||
|
||||
def get_root(self) -> TreeNote:
|
||||
"""Return the root TreeNote (always id=NODE_ROOT_ID)."""
|
||||
return TreeNoteImpl(self, NODE_ROOT_ID)
|
||||
return TreeNoteImpl(self, NOTE_ROOT_ID)
|
||||
|
||||
def open_trove(path: str | Path, create: bool = False) -> Trove:
|
||||
def open_db_trove(path: str | Path, create: bool = False, **kwargs: tr.OpenArguments) -> Trove:
|
||||
return TroveImpl.open(path, create=create)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue