def sync(infile, outfile):
    """
    Sync (download) latest policies from the Anchore.io service.

    """

    ecode = 0
    try:
        rc, ret = anchore_policy.sync_policymeta(bundlefile=infile, outfile=outfile)
        if not rc:
            anchore_print_err(ret['text'])
            ecode = 1
        elif outfile and outfile == '-':
            anchore_print(ret['text'])
    except Exception as err:
        anchore_print_err('operation failed')
        ecode = 1

    sys.exit(ecode)