-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharchive.py
More file actions
38 lines (32 loc) · 1.17 KB
/
archive.py
File metadata and controls
38 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
__all__ = ["app"]
from pathlib import Path
from typing import Annotated
from typer import Argument, Option, Typer
from perdoo.comic import Comic
from perdoo.console import CONSOLE
app = Typer(help="Commands for inspecting and managing comic archive metadata.")
@app.command(help="View the ComicInfo/MetronInfo inside a Comic archive.")
def view(
target: Annotated[
Path,
Argument(dir_okay=False, exists=True, show_default=False, help="Comic to view details of."),
],
hide_comic_info: Annotated[
bool, Option("--hide-comic-info", help="Don't show the ComicInfo details.")
] = False,
hide_metron_info: Annotated[
bool, Option("--hide-metron-info", help="Don't show the MetronInfo details.")
] = False,
) -> None:
comic = Comic(filepath=target)
CONSOLE.print(f"Archive format: '{comic.filepath.suffix}'")
if not hide_metron_info:
if not comic.metron_info:
CONSOLE.print("No MetronInfo found")
else:
comic.metron_info.display()
if not hide_comic_info:
if not comic.comic_info:
CONSOLE.print("No ComicInfo found")
else:
comic.comic_info.display()