aboutsummaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
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)