This repository has been archived by the owner on May 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c9e858
commit db09575
Showing
1 changed file
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |