Drop lots of legacy code. Support Python 3.7-3.11.
[librarian.git] / src / librarian / command_line.py
index 91196f1..08c769f 100644 (file)
@@ -1,3 +1,6 @@
+# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
+#
 import argparse
 import os.path
 from .builders import builders
@@ -9,7 +12,7 @@ def main(*args, **kwargs):
 
     parser.add_argument(
         'builder',
-        choices=[b.identifier for b in builders],
+        choices=builders.keys(),
         help="Builder"
     )
     parser.add_argument('input_file')
@@ -22,7 +25,21 @@ def main(*args, **kwargs):
         help='specifies the directory for output'
     )
 
+    # Specific 
+    parser.add_argument(
+        '-b', '--base-url', metavar="URL",
+        help="Base for relative URLs in documents (like image sources)"
+    )
+
+    parser.add_argument(
+        '--mp3',
+        metavar="FILE",
+        nargs="*",
+        help='specifies an MP3 file, if needed'
+    )
+
     args = parser.parse_args()
+    builder = builders[args.builder]
 
     if args.output_file:
         output_file_path = args.output_file
@@ -38,6 +55,12 @@ def main(*args, **kwargs):
             ))
 
     document = WLDocument(filename=args.input_file)
-    output = document.build(args.builder)
+
+    builder = builders[args.builder]
+    kwargs = {
+        "mp3": args.mp3,
+    }
+
+    output = document.build(builder, base_url=args.base_url, **kwargs)
     with open(output_file_path, 'wb') as f:
         f.write(output.get_bytes())