File size: 967 Bytes
cb21132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import argparse
import logging

from services.shopify_ingest_service import reindex_all, reindex_brand, sync_new_workspace


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description="Sync or re-index Shopify workspace policies.")
    parser.add_argument("--reindex", metavar="SLUG", help="Force re-index one workspace slug.")
    parser.add_argument("--reindex-all", action="store_true", help="Re-index every workspace.")
    return parser.parse_args()


def main() -> None:
    logging.basicConfig(
        level=logging.INFO,
        format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
    )
    args = parse_args()

    if args.reindex and args.reindex_all:
        raise SystemExit("Use either --reindex or --reindex-all, not both.")

    if args.reindex:
        reindex_brand(args.reindex)
    elif args.reindex_all:
        reindex_all()
    else:
        sync_new_workspace()


if __name__ == "__main__":
    main()