aboutsummaryrefslogtreecommitdiff
path: root/src/view/command.py
diff options
context:
space:
mode:
authorJoris2023-09-16 18:28:16 +0200
committerJoris2023-09-16 18:31:24 +0200
commit06f045e90bb57c36738e58ee6830e2a2391bc6a3 (patch)
treea5b65b048c103b4ea0e5d3c0fa5e115cbaf3cf5f /src/view/command.py
parent230f2e0623d22af6e68466884bd5dea5dcb846dc (diff)
Migrate CLI to python
Diffstat (limited to 'src/view/command.py')
-rw-r--r--src/view/command.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/view/command.py b/src/view/command.py
new file mode 100644
index 0000000..e50027f
--- /dev/null
+++ b/src/view/command.py
@@ -0,0 +1,17 @@
+import os
+import shutil
+import subprocess
+import tempfile
+import time
+
+import library.command
+
+def run(book_library, browser_cmd):
+ tmp_dir = tempfile.mkdtemp()
+ directory = os.path.dirname(os.path.realpath(__file__))
+ shutil.copytree(f'{directory}/public', tmp_dir, dirs_exist_ok=True)
+ with open(f'{tmp_dir}/books.js', 'w') as f:
+ json = library.command.get(book_library)
+ f.write(f'const bookLibrary = {json}')
+ browser_cmd = f'{browser_cmd} {tmp_dir}/index.html'
+ subprocess.run(browser_cmd.split(' '))