summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-17 14:01:47 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-17 14:01:47 +0800
commitae02693350eba8b3b1a82ed0f3692b4e41a43f76 (patch)
treee7805c4f0b553da746eb3470b1d5e3ff6f06e87d /main.py
parentb78ed10354119b6a1787db22cd19c1f04986c16d (diff)
added menu & added argument that cna pass through to write.py or read.py
Diffstat (limited to 'main.py')
-rw-r--r--main.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/main.py b/main.py
index a04d1d5..b9cce95 100644
--- a/main.py
+++ b/main.py
@@ -1,8 +1,19 @@
+#!/usr/bin/env python
+
from sys import argv, executable
from os import execv
-if argv[1] == 'write':
- execv(executable, ['python3', 'write.py'])
-elif argv[1] =='read':
- execv(executable, ['python3','read.py'])
+if len(argv) > 1:
+ if argv[1] == 'write':
+ print(' '.join(argv[2:]))
+ execv(executable, ['python3', 'write.py'] + argv[2:])
+ elif argv[1] =='read':
+ execv(executable, ['python3','read.py'])
+ else:
+ raise Exception("Unknown command\n\tAvailable commands: write, read")
else:
- raise Exception("Unknown command") \ No newline at end of file
+ from simple_term_menu import TerminalMenu
+ choice = TerminalMenu(['Write', 'Read']).show()
+ if choice == 0:
+ execv(executable, ['python3', 'write.py'])
+ elif choice == 1:
+ execv(executable, ['python3','read.py']) \ No newline at end of file