aboutsummaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
authorJoris2023-09-16 18:28:54 +0200
committerJoris2023-09-16 18:31:24 +0200
commitc236facb4d4c277773c83f1a4ee85b48833d7e67 (patch)
tree240e72821f7715e24c906e1a2e4081264d47d0ba /src/main.py
parent06f045e90bb57c36738e58ee6830e2a2391bc6a3 (diff)
Add CLI command to insert book in library
Diffstat (limited to 'src/main.py')
-rw-r--r--src/main.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.py b/src/main.py
index 618cc5a..1f07785 100644
--- a/src/main.py
+++ b/src/main.py
@@ -12,10 +12,15 @@ 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
@@ -38,6 +43,16 @@ def get_book_library():
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)