diff --git a/memos/commands.py b/memos/commands.py index 35c4bf8..37ac49e 100644 --- a/memos/commands.py +++ b/memos/commands.py @@ -1,6 +1,7 @@ import typer import httpx from memos.server import run_server +from tabulate import tabulate app = typer.Typer() @@ -12,8 +13,12 @@ def serve(): def ls(): response = httpx.get("http://localhost:8080/libraries") libraries = response.json() + + table = [] 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__": app() diff --git a/memos/models.py b/memos/models.py index 911e378..1da0cbd 100644 --- a/memos/models.py +++ b/memos/models.py @@ -131,5 +131,5 @@ class LibraryPluginModel(Base): # 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) diff --git a/memos/schemas.py b/memos/schemas.py index 22927a3..53ed27b 100644 --- a/memos/schemas.py +++ b/memos/schemas.py @@ -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 datetime import datetime from enum import Enum diff --git a/requirements.txt b/requirements.txt index 1da81bb..52c3046 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ httpx pydantic sqlalchemy typer +tabulate