import argparse
from argparse import RawTextHelpFormatter

d = f"""
You can put some [hopefully] helpful text to remind yourself or your user
how to use this script.

Use --replace to make case-insensitive text replacements when writing the new file.

Examples:
python3 {__file__} -r preston yves -r rohner accad -r yahoo gmail -m *.txt -q
"""

parser = argparse.ArgumentParser(description=d, formatter_class=RawTextHelpFormatter)
parser.add_argument('-m', '--filemask', help='File mask to process.  Default: *.eml', default='*.eml')
parser.add_argument('-r', '--replace', nargs=2, action='append', metavar=('target', 'replacement'), help='Target text to be replaced by replacement. Optional, may be repeated')

group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-v', '--verbose', dest='verbose_mode', action='store_true', help='Print processing progress messages on the screen')
group.add_argument('-q', '--quiet', dest='verbose_mode', action='store_false', help='Print only necessary error messages')

args = parser.parse_args()

print(f'Searching for     : {args.filemask}')
print(f'Verbose Mode      : {args.verbose_mode}')
if args.replace:
    for r in args.replace:
        print(f'   Replacing      : {r[0]} => {r[1]}')