code: def do_cli(ctx, template):
      
  
      sam_template = _read_sam_file(template)
  
      iam_client = boto3.client('iam')
      validator = SamTemplateValidator(sam_template, ManagedPolicyLoader(iam_client))
  
      try:
          validator.is_valid()
      except InvalidSamDocumentException as e:
          click.secho("Template provided at '{}' was invalid SAM Template.".format(template), bg='red')
          raise InvalidSamTemplateException(str(e))
      except NoCredentialsError as e:
          raise UserException("AWS Credentials are required. Please configure your credentials.")
  
      click.secho("{} is a valid SAM Template".format(template), fg='green')
docs: Implementation of the ``cli`` method, just separated out for unit testing purposes