decouple core data from CLI formatting
This commit is contained in:
@@ -3,8 +3,9 @@ from __future__ import annotations
|
||||
from rich import print
|
||||
|
||||
from chromy.chroma_functions import count_collection
|
||||
from chromy.output import format_count_message
|
||||
|
||||
|
||||
def handle_count_collection(collection: str) -> int:
|
||||
print(count_collection(collection))
|
||||
print(format_count_message(collection, count_collection(collection)))
|
||||
return 0
|
||||
|
||||
@@ -2,10 +2,10 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from plistlib import InvalidFileException
|
||||
|
||||
from rich import print
|
||||
|
||||
from chromy.errors import UnsupportedTextFileError
|
||||
from chromy.utilities import ingest_file
|
||||
|
||||
from ..utilities import is_probably_text_file
|
||||
@@ -33,8 +33,8 @@ def handle_import(collection: str, file: str) -> int:
|
||||
absolute_path = _get_absolute_path(file)
|
||||
|
||||
if not is_probably_text_file(absolute_path):
|
||||
raise InvalidFileException()
|
||||
raise UnsupportedTextFileError()
|
||||
|
||||
records_added = ingest_file(collection, _get_absolute_path(file))
|
||||
records_added = ingest_file(collection, absolute_path)
|
||||
print(f"[bold green]Added[/] {records_added} records to collection '{collection}'.")
|
||||
return 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from chromy.chroma_functions import list_collections
|
||||
from chromy.utilities import print_lines
|
||||
from chromy.output import format_collection_names, print_lines
|
||||
|
||||
|
||||
def handle_list_collections() -> int:
|
||||
@@ -11,6 +11,6 @@ def handle_list_collections() -> int:
|
||||
print("No collections found.")
|
||||
return 0
|
||||
|
||||
print_lines(collections)
|
||||
print_lines(format_collection_names(collections))
|
||||
|
||||
return 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from chromy.utilities import format_query_result, print_lines, run_query
|
||||
from chromy.output import format_query_result, print_lines
|
||||
from chromy.utilities import run_query
|
||||
|
||||
|
||||
def handle_query(collection: str, query_text: str) -> int:
|
||||
|
||||
Reference in New Issue
Block a user