From 7a47b4565526fb2ed23d0e636925a66bbfacf3db Mon Sep 17 00:00:00 2001 From: pbrochar <36422268+pbrochar@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:53:34 +0100 Subject: [PATCH] Fix name bug for create command --- blitz/cli/commands/create.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/blitz/cli/commands/create.py b/blitz/cli/commands/create.py index 92194b0..12120f9 100644 --- a/blitz/cli/commands/create.py +++ b/blitz/cli/commands/create.py @@ -65,7 +65,9 @@ class BlitzProjectCreator: DEMO_BLITZ_APP_DESCRIPTION = "This is a demo blitz app" DEMO_BLITZ_APP_NAME = "Demo Blitz App" - def __init__(self, name: str, description: str, file_format: str, demo: bool = False) -> None: + def __init__( + self, name: str, description: str, file_format: str, demo: bool = False + ) -> None: self.name = name self.description = description self.file_format = file_format @@ -93,7 +95,9 @@ def create_file_or_exit(self) -> None: raise typer.Exit(code=1) def print_success_message(self) -> None: - print(f"\n[medium_purple1 bold]{self.name}[/medium_purple1 bold] created successfully !") + print( + f"\n[medium_purple1 bold]{self.name}[/medium_purple1 bold] created successfully !" + ) print("To start your app, you can use:") print(f" [bold medium_purple1]blitz start {self.path}[/bold medium_purple1]") @@ -123,7 +127,9 @@ def _write_blitz_file(self) -> Path: raise Exception() match self.file_format: case "json": - blitz_file_data = self.blitz_file.model_dump_json(indent=4, by_alias=True, exclude_unset=True) + blitz_file_data = self.blitz_file.model_dump_json( + indent=4, by_alias=True, exclude_unset=True + ) case "yaml": blitz_file_data = yaml.dump( self.blitz_file.model_dump(by_alias=True, exclude_unset=True), @@ -145,7 +151,9 @@ def _print_file_error(error: Exception) -> None: @staticmethod def _print_directory_error(error: Exception) -> None: - print(f"[red bold]Error[/red bold] while creating the blitz app in the file system: {error}") + print( + f"[red bold]Error[/red bold] while creating the blitz app in the file system: {error}" + ) def create_blitz_app( @@ -155,12 +163,13 @@ def create_blitz_app( ] = None, demo: Annotated[bool, typer.Option(help="Create a demo blitz app")] = False, ) -> None: + name = blitz_app_name if demo: name = BlitzProjectCreator.DEMO_BLITZ_APP_NAME description = BlitzProjectCreator.DEMO_BLITZ_APP_DESCRIPTION file_format = BlitzProjectCreator.DEFAULT_BLITZ_FILE_FORMAT else: - if not blitz_app_name: + if not name: # Interactive prompt to create a new blitz app name = prompt.Prompt.ask( "Enter the name of your blitz app",