#!/usr/bin/env python

import argparse
import os
import sys

import lib.sccache as sccache


def parse_args():
  parser = argparse.ArgumentParser(description='Run sccache`')

  parser.add_argument('--azure_container', help='Name of azure container to use')
  parser.add_argument('--azure_connection', help='Name of azure connection to use')

  local_args, sccache_args = parser.parse_known_args()
  return local_args, sccache_args


def main():
  local_args, sccache_args = parse_args()

  if local_args.azure_container:
    os.environ['SCCACHE_AZURE_BLOB_CONTAINER'] = local_args.azure_container

  if local_args.azure_connection:
    os.environ['SCCACHE_AZURE_CONNECTION_STRING'] = local_args.azure_connection

  return sccache.run(*sccache_args)


if __name__ == '__main__':
    sys.exit(main())
