#!/usr/bin/python3
import argparse
import sys

from check_multiple.check_multiple import (MODE_BEST,
                                           MODE_WORST,
                                           process_results,
                                           run_commands)


parser = argparse.ArgumentParser(
    description='Run multiple Nagios checks and combine the results.')
parser.add_argument(
    "--mode",
    default='worst',
    choices=['worst', 'best'],
    help="which individual check result should be the overall result; "
         "either the \"worst\" one or the \"best\" one (default: worst)")
parser.add_argument(
    "command",
    nargs="+",
    help="check to run, enclosed in quotes")

args = parser.parse_args()
mode = MODE_WORST
if args.mode == "best":
    mode = MODE_BEST
exitcode,output = process_results(run_commands(args.command), mode)
print(output)
sys.exit(exitcode)
