option_parser.add_option("-y", "--year", default=date.today().year,
                             help="Year in which the race occurred.",
                             type="int")
    options, arguments = option_parser.parse_args(arguments[1:])
    try:
        connect(options.server)
        race = Races.get(int(arguments[0]))
    except ConnectionError, error:
        option_parser.error(error)
    except ValueError:
        race = Races.get(arguments[0], options.year)
    except IndexError:
        option_parser.error("Required positional argument missing.")
    return options, race

@main_function(parse_arguments)
def main(options, race):
    """Read YAML race results from stdin and save them to the specified
    race."""
    try:
        results = load(stdin.read())
    except KeyboardInterrupt:
        return 1
    except ScannerError, error:
        print >> stderr, error
        return 1
    Races.add_results(race, results)

if __name__ == "__main__":
    main()