#!/usr/bin/python3
## Call with "--help" for documentation.

import argparse, certcheck, os

parser = argparse.ArgumentParser(description='Check for soon-to-expire (and already expired) certificates')
parser.add_argument("-d", "--days", metavar='N',
                    dest="days", type=int, default=14,
                    help="Warn about certificates valid for less than N (default 14).")
parser.add_argument("certs",  metavar='CERTS', nargs='+',
                    help="These certificate files are checked. Directories are searched recursively for files called '*.crt'.")
args = parser.parse_args()

for name in args.certs:
    if os.path.isdir(name):
        certcheck.check_dir(name, args.days)
    else:
        certcheck.check_file(name, args.days)
