mirror of
https://github.com/tcsenpai/pensieve.git
synced 2025-06-06 19:25:24 +00:00
feat(cli): ls libraries
This commit is contained in:
parent
dd3b32821d
commit
8caa5c5a7e
@ -1,6 +1,7 @@
|
|||||||
import typer
|
import typer
|
||||||
import httpx
|
import httpx
|
||||||
from memos.server import run_server
|
from memos.server import run_server
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
|
|
||||||
@ -12,8 +13,12 @@ def serve():
|
|||||||
def ls():
|
def ls():
|
||||||
response = httpx.get("http://localhost:8080/libraries")
|
response = httpx.get("http://localhost:8080/libraries")
|
||||||
libraries = response.json()
|
libraries = response.json()
|
||||||
|
|
||||||
|
table = []
|
||||||
for library in libraries:
|
for library in libraries:
|
||||||
print(library['name'])
|
table.append([library['id'], library['name'], "\n".join(folder['path'] for folder in library['folders'])])
|
||||||
|
|
||||||
|
print(tabulate(table, headers=["ID", "Name", "Folders"]))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app()
|
app()
|
||||||
|
@ -131,5 +131,5 @@ class LibraryPluginModel(Base):
|
|||||||
|
|
||||||
|
|
||||||
# Create the database engine with the path from config
|
# Create the database engine with the path from config
|
||||||
engine = create_engine(f"sqlite:///{get_database_path()}", echo=True)
|
engine = create_engine(f"sqlite:///{get_database_path()}")
|
||||||
Base.metadata.create_all(engine)
|
Base.metadata.create_all(engine)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from pydantic import BaseModel, ConfigDict, DirectoryPath, HttpUrl, field_validator
|
from pydantic import BaseModel, ConfigDict, DirectoryPath, HttpUrl
|
||||||
from typing import List
|
from typing import List
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
@ -4,3 +4,4 @@ httpx
|
|||||||
pydantic
|
pydantic
|
||||||
sqlalchemy
|
sqlalchemy
|
||||||
typer
|
typer
|
||||||
|
tabulate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user