#!/usr/bin/env python3

"""Updates older project cards to current format.



If you have a project card that isn't successfully converting using this script or its wrapper,
`/bin/update_project_cards.py`, please open an issue on the projectcard repo with the card.

If you want to address it yourself, please open a pull request with:

1. The card that isn't converting (or similar) added to `/tests/data/cards/` with v0 at end of name.
2. Update the below releveant functions or add a new function and append it to the
    set of functions executed in `update_schema_for_card` function.
3. Validate that the card is converting successfully using the tests in `test_conversion_script.py`.
"""

import sys
from pathlib import Path

from projectcard.update import update_schema_for_card_dir

if len(sys.argv) != 3:
    print("Usage: update_projectcard_schema <card_search_dir | card_filename> <output_dir>")
    sys.exit(1)
card_search_dir_or_filename = Path(sys.argv[1])
output_dir = Path(sys.argv[2])
try:
    update_schema_for_card_dir(card_search_dir_or_filename, output_dir)
except Exception as e:
    sys.exit(1)
sys.exit(0)
