def new()

in solutions_builder/cli/cli.py [0:0]


def new(folder_name,
        output_dir: Annotated[Optional[str], typer.Argument()] = ".",
        template_path: Annotated[str,
                                 typer.Option("--template", "-t")] = None,
        answers=None):
  """
  Create a new solution folder.
  """
  output_path = f"{output_dir}/{folder_name}"
  output_path = output_path.replace("//", "/")
  answers_dict = get_answers_dict(answers)

  if os.path.exists(output_path):
    raise FileExistsError(f"Solution folder {output_path} already exists.")

  # If the component name is a Git URL, use the URL as-is in copier.
  if template_path:
    if check_git_url(template_path):
      template_path = clone_remote_git(template_path)
    else:
      if not os.path.exists(template_path):
        raise FileNotFoundError(
            f"Template '{template_path}' does not exist.")
  else:
    current_dir = os.path.dirname(__file__)
    template_path = f"{current_dir}/../template_root"

  # Copy template_root to destination.
  print(f"template_path: {template_path}\n")
  answers_dict["folder_name"] = folder_name
  verify_copier_file(template_path)
  worker = run_copy(template_path, output_path, data=answers_dict, unsafe=True)

  # Get answer values inputed by user.
  answers = worker.answers.user

  # Optionally set up base terraform
  if answers.get("terraform_base"):
    run_module_template("terraform_base", dest_dir=output_path, data=answers)

  # Optionally set up CI/CD
  cicd_type = answers.get("cicd")
  if cicd_type:
    run_module_template(f"cicd_{cicd_type}",
                        dest_dir=output_path, data=answers)

  print_success(f"Complete. New solution folder created at {output_path}.\n")