Skip to content

Commit

Permalink
Fix name bug for create command
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrochar authored Feb 20, 2024
1 parent d76470b commit 7a47b45
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions blitz/cli/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]")

Expand Down Expand Up @@ -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),
Expand All @@ -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(
Expand All @@ -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",
Expand Down

0 comments on commit 7a47b45

Please sign in to comment.