diff --git a/AGENTS.md b/AGENTS.md index 13a13aa..525c7e1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -85,6 +85,7 @@ mise run project --name "my-project" --description "My app" --author "Your Name" | Deploy docs to GitHub Pages | `mise run docs` | | | Setup dev environment | `mise run dev` | | | Full setup from scratch | `mise run all` | | +| Initialize the project | `mise run init` | | > Refer to `docs/README.md` for the full list of available targets. Add new targets to `mise.toml` as needed. diff --git a/docs/README.md b/docs/README.md index 21a8d00..379bfaa 100644 --- a/docs/README.md +++ b/docs/README.md @@ -39,10 +39,10 @@ Click this button to create a new repository for your project, then clone the ne [![Use this template]( https://img.shields.io/badge/Use%20this%20template-238636?style=for-the-badge)](https://github.com/amrabed/python/generate) -### Rename the project -After cloning the repository, rename the project by running: +### Initialize the project +After cloning the repository, initialize the project by running: ```bash -mise run project +mise run init ``` The script will interactively prompt you for the following details, with smart defaults based on your environment: diff --git a/mise.toml b/mise.toml index 3780608..a22a627 100644 --- a/mise.toml +++ b/mise.toml @@ -91,10 +91,7 @@ description = "Run the app" alias = "a" run = "app" -[tasks.rename] -description = "Rename project (run once)" -alias = "r" -run = "rename" +[tasks.init] +description = "Initialize project (run once)" +run = "init" -[tasks.project] -alias = ["rename", "p"] diff --git a/pyproject.toml b/pyproject.toml index a4e1eeb..eff2e9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ [project.scripts] app = "project.app:main" -rename = "scripts.rename:main" +init = "scripts.init:main" [dependency-groups] dev = [ diff --git a/scripts/rename.py b/scripts/init.py similarity index 96% rename from scripts/rename.py rename to scripts/init.py index c2c359e..7ec9a97 100644 --- a/scripts/rename.py +++ b/scripts/init.py @@ -98,9 +98,9 @@ def main(name: str, description: str, author: str, email: str, github: str): def toml_escape(s: str) -> str: return s.replace("\\", "\\\\").replace('"', '\\"') - description = toml_escape(description) - author = toml_escape(author) - email = toml_escape(email) + escaped_description = toml_escape(description) + escaped_author = toml_escape(author) + escaped_email = toml_escape(email) source = name.replace("-", "_").lower() @@ -138,8 +138,8 @@ def print_field(label: str, value: str): ("pyproject.toml", r"^source = \[.*\]", f'source = ["{source}"]'), ("pyproject.toml", r'^app = "project\.app:main"', f'app = "{source}.app:main"'), ("pyproject.toml", r'^name = ".*"', f'name = "{source}"'), - ("pyproject.toml", r'^description = ".*"', f'description = "{description}"'), - ("pyproject.toml", r"^authors = \[.*\]", f'authors = ["{author} <{email}>"]'), + ("pyproject.toml", r'^description = ".*"', f'description = "{escaped_description}"'), + ("pyproject.toml", r"^authors = \[.*\]", f'authors = ["{escaped_author} <{escaped_email}>"]'), ("docs/README.md", r"^# .*", f"# {description}"), (".github/CODEOWNERS", r"@.*", f"@{github}"), (".github/FUNDING.yml", r"^github: \[.*\]", f"github: [{github}]"),