code: def handle_args_and_set_context(args):
    
    parser = argparse.ArgumentParser()
    parser.add_argument("env", help=", ".join(EFConfig.ENV_LIST))
    parser.add_argument("--sr", help="optional /path/to/service_registry_file.json", default=None)
    parser.add_argument("--commit", help="Make changes in AWS (dry run if omitted)", action="store_true", default=False)
    parser.add_argument("--verbose", help="Print additional info", action="store_true", default=False)
    parser.add_argument("--devel", help="Allow running from branch; don't refresh from origin", action="store_true",
                        default=False)
    parsed_args = vars(parser.parse_args(args))
    context = EFContext()
    context.commit = parsed_args["commit"]
    context.devel = parsed_args["devel"]
    try:
      context.env = parsed_args["env"]
    except ValueError as e:
      fail("Error in env: {}".format(e.message))
    # Set up service registry and policy template path which depends on it
    context.service_registry = EFServiceRegistry(parsed_args["sr"])
    context.policy_template_path = normpath(dirname(context.service_registry.filespec)) + EFConfig.POLICY_TEMPLATE_PATH_SUFFIX
    context.verbose = parsed_args["verbose"]
    return context
docs: Args:
      args: the command line args, probably passed from main() as sys.argv[1:]
    Returns:
      a populated EFContext object
    Raises:
      IOError: if service registry file can't be found or can't be opened
      RuntimeError: if repo or branch isn't as spec'd in ef_config.EF_REPO and ef_config.EF_REPO_BRANCH
      CalledProcessError: if 'git rev-parse' command to find repo root could not be run