diff --git a/docs/template/default.md b/docs/template/internal.md similarity index 98% rename from docs/template/default.md rename to docs/template/internal.md index 9d54d895..9edeb619 100644 --- a/docs/template/default.md +++ b/docs/template/internal.md @@ -1,4 +1,4 @@ -# The 'Default' Template +# The Internal Template By default, the generated application will have a basic template that you can use to get started, this template is stored inside the package itself. It will diff --git a/docs/template/modify.md b/docs/template/modify.md index 98ab4c07..7a8da179 100644 --- a/docs/template/modify.md +++ b/docs/template/modify.md @@ -1,9 +1,8 @@ # Adding or Modifying files in the template -If you always wish to add or change specific files in the template, you can do -so by adding them to the `~/.pymaker/template` folder. The files (and folders) -in this folder will be copied to the root of the project when the template is -generated. +If you wish to add or change specific files in the template, you can do so by +adding them to the `~/.pymaker/template` folder. The files (and folders) in this +folder will be copied to the root of the project when the template is generated. Files in this global template folder will override any files in the default template, so you can for example change the `README.md` file, add to the diff --git a/docs/template/replace.md b/docs/template/replace.md index 39fcfdd5..d8c340a2 100644 --- a/docs/template/replace.md +++ b/docs/template/replace.md @@ -18,14 +18,30 @@ This will copy the default template to the global template folder (`~/.pymaker/template`). You can then modify or delete files as you see fit. Running this command will ask you if you wish to set this exported template as -the default template. If you answer yes, then the default template will be +the default template. It will then ask you if you want to disable the internal +template. If you answer yes, then the internal template will be disabled, and ONLY the exported template will be used instead. Otherwise, both will still be used with the exported template taking precedence. -## Use another Template completely +## Change the location of the Template folder -!!! note - This feature is not yet implemented. +If you wish to change the location of the template folder, you can do so in 2 +ways: + +1. By adding the `--local` flag to the above command (e.g. `pymaker template + dump --local`). This will dump the default template to the current folder, + giving you the option to disable the default template if needed. Note that + any files in the folder will be overwritten. +2. By changing to the folder containing your template and running `pymaker + template set`. This will set the current folder as the template folder and + give you the same option to disable the default template. + +You can reset the template location back to the default `~/.pymaker/template` +folder by running the following command: + +```console +$ pymaker template reset +``` ## Choose to use the Default Template or not diff --git a/mkdocs.yml b/mkdocs.yml index 0d33215d..e63dfb86 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -56,7 +56,7 @@ nav: - Quick Start: quick-start.md - Configuration: configuration.md - Templates: - - Default Template: template/default.md + - Internal Template: template/internal.md - Modifying: template/modify.md - Replacing: template/replace.md - Task Runner: tasks.md diff --git a/py_maker/commands/template.py b/py_maker/commands/template.py index 38b56ec6..3c23bc30 100644 --- a/py_maker/commands/template.py +++ b/py_maker/commands/template.py @@ -45,7 +45,7 @@ def dump( if any(output_folder.iterdir()) and not Confirm.ask( f"[red]The output folder:[/red] {output_folder} " - f"[red]is not empty, do you want to continue?[/red]", + "[red]is not empty, do you want to continue?[/red]", default=False, ): raise typer.Exit(ExitErrors.USER_ABORT) # noqa TRY301 @@ -102,7 +102,7 @@ def default(action: str) -> None: settings.use_default_template = True settings.save() print( - f"[green] -> Default template folder enabled:[/green] " + "[green] -> Default template folder enabled:[/green] " f"{settings.template_folder}" ) elif action == "disable": @@ -112,7 +112,7 @@ def default(action: str) -> None: else: print( f"[red] -> Invalid action:[/red] {action}\n" - f"[red] -> Action must be either:[/red] enable or disable" + "[red] -> Action must be either:[/red] enable or disable" ) raise typer.Exit(ExitErrors.INVALID_ACTION) @@ -135,7 +135,7 @@ def set_template(): settings.save() print( - f"[green] -> Template folder set to:[/green] " + "[green] -> Template folder set to:[/green] " f"{settings.template_folder}" ) print( @@ -165,7 +165,7 @@ def reset_template(): settings.template_folder = str(Path.home() / ".pymaker" / "template") settings.save() print( - f"[green] -> Template folder reset to:[/green] " + "[green] -> Template folder reset to:[/green] " f"{settings.template_folder}" ) print(