-
Notifications
You must be signed in to change notification settings - Fork 0
/
oak.py
85 lines (63 loc) · 1.91 KB
/
oak.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import typer
import shutil
from collections import defaultdict
import commands.add
import commands.enrich
import commands.edit
import commands.export
import commands.sync
import commands.reset
import commands.save
import commands.make
from commands.stats import generate_stats
app = typer.Typer(pretty_exceptions_show_locals=False)
app.add_typer(commands.add.app, name="add", short_help="Add books to the library.")
app.add_typer(
commands.enrich.app,
name="enrich",
short_help="Enrich books already in the library.",
)
@app.command()
def reset():
"""Reset the library."""
commands.reset.reset_library()
@app.command()
def save():
"""Save current attribute states so it can be used to enrich the data later on."""
commands.save.save_attributes()
@app.command()
def load():
"""Load current attribute states from save file."""
commands.save.load_attributes()
@app.command()
def make(export_date: str, ask: bool = False):
"""Save current attribute states so it can be used to enrich the data later on."""
commands.make.make_catalogue(export_date, quiet=not ask)
@app.command()
def sync():
"""Sync books folders."""
commands.sync.sync_folders(
"./output/books", "../flpm.github.io/bookshelf/books", "books"
)
commands.sync.sync_folders(
"./output/lists", "../flpm.github.io/bookshelf/lists", "lists"
)
shutil.copytree(
"./output/covers",
"../flpm.github.io/bookshelf/covers",
dirs_exist_ok=True,
)
@app.command()
def edit():
"""Edit books in the library."""
commands.edit.run_edit_loop()
@app.command()
def export(target_folder: str = "./output"):
"""Export books as Markdown files."""
commands.export.export_markdown(target_folder)
@app.command()
def stats(stats_type: str = "attributes"):
"""Show stats about the current catalog."""
generate_stats(stats_type)
if __name__ == "__main__":
app()