diff --git a/pyproject.toml b/pyproject.toml index 2154e57..364d8ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "repo-template" +name = "repo-scaffold" version = "0.1.0" description = "shawn deng repo temple project" authors = ["colyerdeng "] @@ -18,11 +18,11 @@ pre-commit = "^4.0.1" commitizen = "^4.1.0" [tool.poetry.scripts] -repo-template = "repo_template.cli:cli" +repo-scaffold = "repo_scaffold.cli:cli" [tool.ruff] line-length = 120 -include = ["pyproject.toml", "{{template-python}}/{{cookiecutter.project_slug}}/*.py"] +include = ["pyproject.toml", "repo_scaffold/*.py"] [tool.ruff.lint] select = [ diff --git a/repo_scaffold/__init__.py b/repo_scaffold/__init__.py new file mode 100644 index 0000000..7097b4e --- /dev/null +++ b/repo_scaffold/__init__.py @@ -0,0 +1,18 @@ +"""Repository scaffolding package for project initialization and setup. + +This package provides tools and utilities for scaffolding new Python projects +with standardized structure and best practices. It serves as the main entry point +for the repo_scaffold package functionality. + +Typical usage example: + + import repo_scaffold + + scaffold = repo_scaffold.create_project() + scaffold.setup_structure() + +Attributes: + __author__: Package author information. +""" + +__author__ = "Shawn Deng" diff --git a/repo_scaffold/cli.py b/repo_scaffold/cli.py new file mode 100644 index 0000000..f36d598 --- /dev/null +++ b/repo_scaffold/cli.py @@ -0,0 +1,65 @@ +"""Command Line Interface module for project scaffolding. + +This module provides the CLI commands for creating new projects using cookiecutter +templates. It serves as the main entry point for the repo_scaffold tool and handles +all command-line interactions. + +Typical usage example: + + from repo_scaffold.cli import cli + + if __name__ == '__main__': + cli() + +Attributes: + cli: The main Click command group that serves as the entry point. +""" + +import os + +import click +from cookiecutter.main import cookiecutter + + +@click.group() +def cli(): + """CLI tool for project creation. + + This function serves as the main command group for the CLI application. + It groups all subcommands and provides the base entry point for the tool. + """ + ... + + +@cli.command() +@click.option( + "--template", + "-t", + default="https://github.com/ShawnDen-coder/repo-template.git", + help="Cookiecutter template URL or path", +) +@click.option("--output-dir", "-o", default=".", help="Where to output the generated project dir") +@click.option("--local", "-l", is_flag=True, help="Use local template in ./template-python") +def create(template, output_dir, local): + """Create a new project from a Cookiecutter template. + + Args: + template (str): URL or path to the cookiecutter template. + output_dir (str): Directory where the generated project will be created. + local (bool): Flag to use local template instead of remote. + + Returns: + None + + Example: + $ repo_scaffold create --template https://github.com/user/template.git + $ repo_scaffold create --local --output-dir ./projects + """ + if local: + template = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) + + cookiecutter(template=template, output_dir=output_dir, no_input=False) + + +if __name__ == "__main__": + cli() diff --git a/repo_scaffold/utils.py b/repo_scaffold/utils.py new file mode 100644 index 0000000..d7fdf4a --- /dev/null +++ b/repo_scaffold/utils.py @@ -0,0 +1,17 @@ +"""Utility functions module for common operations. + +This module contains reusable utility functions that can be used across the application. +It provides helper methods, convenience functions, and shared functionality to promote +code reuse and maintainability. + +Typical usage example: + + from repo_scaffold.utils import validate_input, format_output + + cleaned_data = validate_input(raw_data) + result = format_output(cleaned_data) + +Note: + All utility functions should be stateless and follow single responsibility principle. + New utility functions should be well documented with type hints and docstrings. +""" diff --git a/repo_template/__init__.py b/repo_template/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/repo_template/cli.py b/repo_template/cli.py deleted file mode 100644 index 872004f..0000000 --- a/repo_template/cli.py +++ /dev/null @@ -1,31 +0,0 @@ -import os - -import click -from cookiecutter.main import cookiecutter - - -@click.group() -def cli(): - """CLI tool for project creation""" - ... - - -@cli.command() -@click.option('--template', '-t', default='https://github.com/ShawnDen-coder/repo-template.git', - help='Cookiecutter template URL or path') -@click.option('--output-dir', '-o', default='.', help='Where to output the generated project dir') -@click.option('--local', '-l', is_flag=True, help='Use local template in ./template-python') -def create(template, output_dir, local): - """Create a new project from a Cookiecutter template""" - if local: - template = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) - - cookiecutter( - template=template, - output_dir=output_dir, - no_input=False - ) - - -if __name__ == '__main__': - cli() diff --git a/repo_template/utils.py b/repo_template/utils.py deleted file mode 100644 index e69de29..0000000 diff --git a/template-python/hooks/post_gen_project.py b/template-python/hooks/post_gen_project.py index 3edfbd2..0592af3 100644 --- a/template-python/hooks/post_gen_project.py +++ b/template-python/hooks/post_gen_project.py @@ -1,6 +1,5 @@ import os import subprocess -from githubkit import GitHub def remove_cli():