add list, create, delete commands

This commit is contained in:
2026-04-21 14:32:10 +02:00
parent bac81cbd33
commit 2b07bf471d
3 changed files with 109 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
from __future__ import annotations
from chromadb.errors import NotFoundError, InternalError
from chroma_functions import create_collection, delete_collection, list_collections
from cli_parser import build_parser
def main() -> int:
args = build_parser().parse_args()
if args.command in {"list-collections", "lc"}:
collections = list_collections()
if not collections:
print("No collections found.")
return 0
for name in collections:
print(name)
return 0
if args.command in {"create-collection", "cc"}:
try:
create_collection(args.name)
except InternalError:
print(f"Collection '{args.name}' already exists.")
return 1
print(f"Created collection '{args.name}'.")
return 0
if args.command in {"delete-collection", "dc"}:
try:
delete_collection(args.name)
except NotFoundError:
print(f"Collection '{args.name}' does not exist.")
return 1
print(f"Deleted collection '{args.name}'.")
return 0
# TODO Implement the count command.
print("Nothing to do. Use -h to see available commands.")
return 0
if __name__ == "__main__":
raise SystemExit(main())