diff --git a/README.md b/README.md index 2952a98..8ca7cb1 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Rough Editor +# The README is not accurate at the moment! ## Description diff --git a/regex-test.py b/regex-test.py index 1fa4b80..63c9298 100755 --- a/regex-test.py +++ b/regex-test.py @@ -1,10 +1,9 @@ import re import os -from datetime import timedelta -import json from rough_edit.utils import str_to_timedelta, escape_string, generate_regex from rough_edit.file_writers import ffmpeg_command, mpv_command +from rough_edit.handle_arguments import handle_arguments if __name__ == '__main__': @@ -12,11 +11,9 @@ if __name__ == '__main__': subs_dir = f"{baseDir}subs/" outDir = f"{baseDir}out/" - phrase = "I don't know" + phrase, padding_left, padding_right = handle_arguments() regex = generate_regex(phrase) - padding_left = timedelta(seconds=3) - padding_right = timedelta(seconds=3) count = 0 with open('rip.sh', 'w') as rip_file: diff --git a/rough_edit/handle_arguments.py b/rough_edit/handle_arguments.py new file mode 100755 index 0000000..c5b2342 --- /dev/null +++ b/rough_edit/handle_arguments.py @@ -0,0 +1,23 @@ +import sys +from datetime import timedelta + +def print_expected_call_message(additional_message): + print(f"""{additional_message} +Expected application call: +python3 regex_text.py [searched phrase] [left_padding] [right_padding] +Example call: +python3 regex_text.py "I don't know" 2 3""") + + + +def handle_arguments(): + if not (arg_len := len(sys.argv)) == 4: + print_expected_call_message(f'Expected two arguments, got {arg_len-1}.') + exit() + try: + phrase = sys.argv[1] + padding_left, padding_right = [timedelta(int(number)) for number in sys.argv[2:4]] + return([phrase, padding_left, padding_right]) + except: + print_expected_call_message(f'An error has occured.') + exit()