Fix multiple error cases reached

With `textual run --dev "src.textual_paint.gallery foobar"` it output:

    Folder not found: foobar
    Not a folder: foobar
    No ANSI art (*.ans, *.txt) found in folder: foobar

    NOTE: 3 errors shown above.

Now it correctly outputs only:

    Folder not found: foobar
This commit is contained in:
Isaiah Odhner 2023-09-06 13:32:41 -04:00
parent 5441c0d3b0
commit f1d6b266aa

View File

@ -99,9 +99,12 @@ class GalleryApp(App[None]):
if not gallery_folder.exists():
self.exit(None, f"Folder not found: {gallery_folder}")
return
if not gallery_folder.is_dir():
# TODO: allow showing a specific file, and load whatever folder it's in
self.exit(None, f"Not a folder: {gallery_folder}")
return
exts = (".ans", ".txt")
@ -129,6 +132,7 @@ class GalleryApp(App[None]):
# Debugging
# self.exit(None, "\n".join(str(path) for path in paths))
# return
for path in paths:
if path.suffix not in exts:
@ -141,6 +145,7 @@ class GalleryApp(App[None]):
if len(self.scroll.children) == 0:
self.exit(None, f"No ANSI art ({', '.join(f'*{ext}' for ext in exts)}) found in folder: {gallery_folder}")
return
def _scroll_to_adjacent_item(self, delta_index: int = 0) -> None:
"""Scroll to the next/previous item."""