From ae02693350eba8b3b1a82ed0f3692b4e41a43f76 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 17 Oct 2023 14:01:47 +0800 Subject: added menu & added argument that cna pass through to write.py or read.py --- main.py | 21 ++++++++++++++++----- 1 file 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 -- cgit v1.2.3