aboutsummaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.py')
-rw-r--r--src/main.py71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/main.py b/src/main.py
deleted file mode 100644
index 1f07785..0000000
--- a/src/main.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Manage book library.
-#
-# Required dependencies:
-#
-# - python >= 3.11
-# - requests
-# - pillow
-# - ebook-convert CLI (from calibre)
-
-import sys
-import os
-
-import library.command
-import view.command
-import new.command
-
-def print_help(title='Manage book library'):
- print(f"""{title}
-
-- Insert book entry with optional ebook file:
-
- $ python {sys.argv[0]} new [path-to-book]
-
-- Print library metadata as json:
-
- $ python {sys.argv[0]} library
-
-- View books in web page:
-
- $ python {sys.argv[0]} view browser-cmd
-
-Environment variables:
-
- BOOK_LIBRARY: path to book library.""")
-
-def get_book_library():
- path = os.getenv('BOOK_LIBRARY')
- if path is None or not os.path.isdir(path):
- print_help(title='BOOK_LIBRARY environment variable is required.')
- exit(1)
- else:
- return path
-
-def main():
- match sys.argv:
- case [ _, 'new' ]:
- book_library = get_book_library()
- new.command.run(book_library)
- case [ _, 'new', book_source ]:
- if os.path.isfile(book_source):
- book_library = get_book_library()
- new.command.run(book_library, book_source)
- else:
- print_help(title=f'File not found: {book_source}.')
- exit(1)
- case [ _, 'library' ]:
- book_library = get_book_library()
- library.command.run(book_library)
- case [ _, 'view', browser_cmd ]:
- book_library = get_book_library()
- view.command.run(book_library, browser_cmd)
- case [ _, '--help' ]:
- print_help()
- case [ _, '-h' ]:
- print_help()
- case _:
- print_help('Command not found.')
- exit(1)
-
-if __name__ == "__main__":
- main()