Skip to content

Commit

Permalink
Add a prompt when a user creates a project which shares a name with a…
Browse files Browse the repository at this point in the history
…n existing remote (#50)

Fixes a bug where if a user created a project with the same name as an existing remote, the new
project would overwrite the existing config which could lead to some confusion.
  • Loading branch information
snow0x2d0 committed Jan 10, 2022
1 parent e10724f commit 3701c40
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions webex_skills/cli/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ def init(
):
"""Create a new skill project from a template"""

# Check for an existing skill name and provide an option to overwrite
if get_skill_config(skill_name):
if not typer.confirm(
f'A skill named {skill_name} already exists in your configuration. Would you like to overwrite it?'
):
return

if not secret:
typer.secho('Generating secret...')
secret = secrets.token_urlsafe(16)
Expand Down Expand Up @@ -106,9 +113,7 @@ def _create_project(

# Create pyproject.toml
toml_template = static_path / 'pyproject.toml.tmpl'
toml_content = toml_template.read_text()

toml_content = toml_content.format(skill_name=skill_name)
toml_content = toml_template.read_text().format(skill_name=skill_name)
toml_out_path = output_dir / 'pyproject.toml'
toml_out_path.write_text(toml_content)

Expand Down

0 comments on commit 3701c40

Please sign in to comment.