-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
55 lines (48 loc) · 1.4 KB
/
cli.py
File metadata and controls
55 lines (48 loc) · 1.4 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from typing import Annotated
import typer
from converter import converter
app = typer.Typer(
help="EPUB to HTML converter with some custom HTML/CSS so it's easy to navigate between chapters",
short_help="EPUB to HTML converter",
add_help_option=True,
name="Etohr",
suggest_commands=True,
rich_markup_mode=None,
pretty_exceptions_enable=False
)
PROJECT_VERSION="0.1.0"
@app.command()
def convert(
filepath: Annotated[str, typer.Option(
"-f", "--filepath",
help="Filepath to the EPUB file",
envvar="ETOHR_BOOK")],
output_directory: Annotated[str | None, typer.Option(
"-o", "--output-directory",
help="Output folder for the EPUB file",
envvar="ETOHR_OUTPUT_DIRECTORY")] = "output"):
'''
Convert an EPUB file to a collection of HTML files with some additionnal HTML/CSS for easier navigation
'''
converter(filepath, output_directory)
@app.command()
def version():
'''
Show the version of the project
'''
print(f'''
Version: {PROJECT_VERSION}
''')
@app.command()
def info():
'''
Show information about the project
'''
print('''
Version: {PROJECT_VERSION}
Github: https://github.com/BastienBYRA/epub-to-html-reader
Issue: https://github.com/BastienBYRA/epub-to-html-reader/issues
Want to help: https://github.com/BastienBYRA/epub-to-html-reader/issues
''')
if __name__ == "__main__":
app()