Skip to content

Commit

Permalink
perf: make init faster and name
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Oct 30, 2024
1 parent 84928c5 commit abe73c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ape_init/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from click import BadParameter

from ape.cli.options import ape_cli_context
from ape.utils._github import github_client

GITIGNORE_CONTENT = """
# Ape stuff
Expand Down Expand Up @@ -45,12 +44,15 @@ def validate_github_repo(ctx, param, value):
help="Clone a template from Github",
callback=validate_github_repo,
)
def cli(cli_ctx, github):
@click.option("--name", "project_name", prompt=True, help="A project name")
def cli(cli_ctx, github, project_name):
"""
``ape init`` allows the user to create an ape project with
default folders and ape-config.yaml.
"""
if github:
from ape.utils._github import github_client

org, repo = github
github_client.clone_repo(org, repo, Path.cwd())
shutil.rmtree(Path.cwd() / ".git", ignore_errors=True)
Expand All @@ -76,6 +78,5 @@ def cli(cli_ctx, github):
if ape_config.exists():
cli_ctx.logger.warning(f"'{ape_config}' exists")
else:
project_name = click.prompt("Please enter project name")
ape_config.write_text(f"name: {project_name}\n", encoding="utf8")
cli_ctx.logger.success(f"{project_name} is written in ape-config.yaml")

0 comments on commit abe73c5

Please sign in to comment.