From db09575e69eda565cf851f5882d120bef8dcb5d2 Mon Sep 17 00:00:00 2001 From: Hirusha Adikari <36286877+hirusha-adi@users.noreply.github.com> Date: Tue, 23 Jan 2024 22:59:53 +0530 Subject: [PATCH] implementation --- search.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/search.py b/search.py index 58c79b5..010953f 100644 --- a/search.py +++ b/search.py @@ -1,3 +1,24 @@ +import argparse +import os from docx_search import docx_search -docx_search() +def main(): + parser = argparse.ArgumentParser(description='Search for a word in .docx files in a specified directory.') + parser.add_argument( + '--dir', dest='target_dir', type=str, default=os.getcwd(), + help='The target directory to search for .docx files. Defaults to the current working directory.' + ) + parser.add_argument('--word', dest='target_word', type=str, + help='The word to search for in the documents. If not provided, user will be prompted.') + args = parser.parse_args() + + target_dir = args.target_dir + target_word = args.target_word + + if not target_word: + target_word = input("Enter the word to search for: ") + + docx_search(target_dir=target_dir, target_word=target_word) + +if __name__ == "__main__": + main()