From c241fab93751528ca95137da82158af303d3d0cc Mon Sep 17 00:00:00 2001 From: #Einswilli Date: Sun, 29 Mar 2026 18:08:15 +0000 Subject: [PATCH 1/4] feat(newproject): add --no-project-dir flag to allow scaffolding in current directory like django-admin startproject --- fletx/cli/commands/newproject.py | 62 +++++++++++++++++++------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/fletx/cli/commands/newproject.py b/fletx/cli/commands/newproject.py index 0cbcbf9..e05e2cf 100644 --- a/fletx/cli/commands/newproject.py +++ b/fletx/cli/commands/newproject.py @@ -60,6 +60,11 @@ def add_arguments(self, parser: CommandParser) -> None: action="store_true", help="Don't install dependencies after creating the project", ) + parser.add_argument( + "--no-project-dir", + action="store_true", + help="Generate project files in the target directory instead of creating a subdirectory with the project name", + ) def handle(self, **kwargs) -> None: """Handle the new project command.""" @@ -78,13 +83,17 @@ def handle(self, **kwargs) -> None: self.validate_name(name) # Determine target directory - if directory: - target_dir = Path(directory) / name + no_project_dir = kwargs.get("no_project_dir", False) + if no_project_dir: + target_dir = Path(directory) if directory else Path.cwd() else: - target_dir = Path.cwd() / name + if directory: + target_dir = Path(directory) / name + else: + target_dir = Path.cwd() / name - # Check if project directory already exists - if target_dir.exists() and not overwrite: + # Check if project directory already exists (unless we are scaffolding in place) + if not no_project_dir and target_dir.exists() and not overwrite: if any(target_dir.iterdir()): raise CommandExecutionError( f"Directory '{target_dir}' already exists and is not empty. " @@ -113,27 +122,29 @@ def handle(self, **kwargs) -> None: "fletx_version": __version__, } - try: - # Generate project from template - print(f"Creating new FletX project '{name}'...") - template_manager.generate_from_template( - template, target_dir, context, overwrite - ) - - print(f"\nProject '{name}' created successfully at: {target_dir}") + try: + # Generate project from template + print(f"Creating new FletX project '{name}'...") + template_manager.generate_from_template( + template, target_dir, context, overwrite + ) - # Create project configuration - self._create_project_config(target_dir, context) + if no_project_dir: + print(f"\nProject '{name}' created successfully in the current directory: {target_dir}") + else: + print(f"\nProject '{name}' created successfully at: {target_dir}") - # Install dependencies if requested - if not no_install: - self._install_dependencies(target_dir) + # Create project configuration + self._create_project_config(target_dir, context) - # Print next steps - self._print_next_steps(name, target_dir, no_install) + # Install dependencies if requested + if not no_install: + self._install_dependencies(target_dir) - except Exception as e: - raise CommandExecutionError(f"Failed to create project: {e}") + # Print next steps + self._print_next_steps(name, target_dir, no_install, no_project_dir) + except Exception as e: + raise CommandExecutionError(f"Failed to create project: {e}") def _create_project_config(self, project_dir: Path, context: dict) -> None: """Create project configuration file.""" @@ -187,7 +198,7 @@ def _install_dependencies(self, project_dir: Path) -> None: ) def _print_next_steps( - self, project_name: str, project_dir: Path, no_install: bool + self, project_name: str, project_dir: Path, no_install: bool, no_project_dir: bool = False ) -> None: """Print next steps for the user.""" @@ -195,7 +206,10 @@ def _print_next_steps( print("🎉 Project created successfully!") print("=" * 50) print("\nNext steps:") - print(" 1. cd {project_dir.name}") + if no_project_dir: + print(" 1. The files have been generated in the current directory.") + else: + print(f" 1. cd {project_dir.name}") if no_install: print(" 2. pip install -r requirements.txt") From 53e9badd264911f26db00910da0e7fb396f1b92d Mon Sep 17 00:00:00 2001 From: #Einswilli Date: Sun, 29 Mar 2026 18:23:20 +0000 Subject: [PATCH 2/4] feat(newproject): support '.' as directory to scaffold in current directory and improve --no-project-dir behavior --- fletx/cli/commands/newproject.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fletx/cli/commands/newproject.py b/fletx/cli/commands/newproject.py index e05e2cf..0997d9f 100644 --- a/fletx/cli/commands/newproject.py +++ b/fletx/cli/commands/newproject.py @@ -84,13 +84,18 @@ def handle(self, **kwargs) -> None: # Determine target directory no_project_dir = kwargs.get("no_project_dir", False) - if no_project_dir: - target_dir = Path(directory) if directory else Path.cwd() + # Special case: if directory is ".", treat as no-project-dir (scaffold in current directory) + if directory == ".": + no_project_dir = True + target_dir = Path.cwd() else: - if directory: - target_dir = Path(directory) / name + if no_project_dir: + target_dir = Path(directory) if directory else Path.cwd() else: - target_dir = Path.cwd() / name + if directory: + target_dir = Path(directory) / name + else: + target_dir = Path.cwd() / name # Check if project directory already exists (unless we are scaffolding in place) if not no_project_dir and target_dir.exists() and not overwrite: From ac26922d469726dfc58b828527209aa43c23ee8f Mon Sep 17 00:00:00 2001 From: #Einswilli Date: Sun, 29 Mar 2026 18:29:00 +0000 Subject: [PATCH 3/4] feat(newproject): make directory argument optional and improve help text --- fletx/cli/commands/newproject.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fletx/cli/commands/newproject.py b/fletx/cli/commands/newproject.py index 0997d9f..8d47d68 100644 --- a/fletx/cli/commands/newproject.py +++ b/fletx/cli/commands/newproject.py @@ -31,9 +31,9 @@ def add_arguments(self, parser: CommandParser) -> None: help="Template to use for the project (default: project)", ) parser.add_argument( - "-D", - "--directory", - help="Directory where the project should be created (default: current directory)", + "directory", + nargs="?", + help="Directory where the project should be created. If not provided, uses current directory. Use '.' to scaffold in current directory without creating a project subdirectory.", ) parser.add_argument("--author", help="Author name for the project") parser.add_argument("-d", "--description", help="Project description") @@ -63,7 +63,7 @@ def add_arguments(self, parser: CommandParser) -> None: parser.add_argument( "--no-project-dir", action="store_true", - help="Generate project files in the target directory instead of creating a subdirectory with the project name", + help="Generate project files in the target directory instead of creating a subdirectory with the project name. Also implied when directory is '.'.", ) def handle(self, **kwargs) -> None: From 2623bdb08672c090eda4508d01963f8101b464e2 Mon Sep 17 00:00:00 2001 From: #Einswilli Date: Sun, 29 Mar 2026 18:51:25 +0000 Subject: [PATCH 4/4] feat(newproject): add support for '.' directory and --no-project-dir flag to scaffold in current directory like django-admin startproject --- fletx/cli/commands/newproject.py | 54 ++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/fletx/cli/commands/newproject.py b/fletx/cli/commands/newproject.py index 8d47d68..bc20ead 100644 --- a/fletx/cli/commands/newproject.py +++ b/fletx/cli/commands/newproject.py @@ -127,29 +127,31 @@ def handle(self, **kwargs) -> None: "fletx_version": __version__, } - try: - # Generate project from template - print(f"Creating new FletX project '{name}'...") - template_manager.generate_from_template( - template, target_dir, context, overwrite - ) - - if no_project_dir: - print(f"\nProject '{name}' created successfully in the current directory: {target_dir}") - else: - print(f"\nProject '{name}' created successfully at: {target_dir}") - - # Create project configuration - self._create_project_config(target_dir, context) - - # Install dependencies if requested - if not no_install: - self._install_dependencies(target_dir) - - # Print next steps - self._print_next_steps(name, target_dir, no_install, no_project_dir) - except Exception as e: - raise CommandExecutionError(f"Failed to create project: {e}") + try: + # Generate project from template + print(f"Creating new FletX project '{name}'...") + template_manager.generate_from_template( + template, target_dir, context, overwrite + ) + + if no_project_dir: + print( + f"\nProject '{name}' created successfully in the current directory: {target_dir}" + ) + else: + print(f"\nProject '{name}' created successfully at: {target_dir}") + + # Create project configuration + self._create_project_config(target_dir, context) + + # Install dependencies if requested + if not no_install: + self._install_dependencies(target_dir) + + # Print next steps + self._print_next_steps(name, target_dir, no_install, no_project_dir) + except Exception as e: + raise CommandExecutionError(f"Failed to create project: {e}") def _create_project_config(self, project_dir: Path, context: dict) -> None: """Create project configuration file.""" @@ -203,7 +205,11 @@ def _install_dependencies(self, project_dir: Path) -> None: ) def _print_next_steps( - self, project_name: str, project_dir: Path, no_install: bool, no_project_dir: bool = False + self, + project_name: str, + project_dir: Path, + no_install: bool, + no_project_dir: bool = False, ) -> None: """Print next steps for the user."""