From 5167b804451fe262e2612545c710425f63257b59 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 5 Feb 2026 08:45:44 +0000 Subject: [PATCH] Add utils, templates, config, interactive, and github modules --- src/auto_readme/interactive/__init__.py | 139 ++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 src/auto_readme/interactive/__init__.py diff --git a/src/auto_readme/interactive/__init__.py b/src/auto_readme/interactive/__init__.py new file mode 100644 index 0000000..71f96fa --- /dev/null +++ b/src/auto_readme/interactive/__init__.py @@ -0,0 +1,139 @@ +"""Interactive wizard for customizing README content.""" + +from pathlib import Path +from typing import Optional + +import click + +from ..models import Project + + +class ProjectInfoWizard: + """Wizard for collecting project information.""" + + @staticmethod + def run(project: Project) -> Project: + """Run the project info wizard.""" + if not project.config: + project.config.name = project.root_path.name + + project.config.name = click.prompt( + "Project name", + default=project.config.name if project.config else project.root_path.name, + ) + + project.config.description = click.prompt( + "Project description", + default=project.config.description or "A project generated by auto-readme", + ) + + project.config.author = click.prompt( + "Author (optional)", + default=project.config.author or "", + show_default=False, + ) + + project.config.email = click.prompt( + "Email (optional)", + default=project.config.email or "", + show_default=False, + ) + + project.config.license = click.prompt( + "License (optional)", + default=project.config.license or "MIT", + show_default=False, + ) + + return project + + +class SectionWizard: + """Wizard for customizing README sections.""" + + SECTION_OPTIONS = [ + ("overview", "Project Overview"), + ("installation", "Installation"), + ("usage", "Usage"), + ("features", "Features"), + ("api", "API Reference"), + ("contributing", "Contributing"), + ("license", "License"), + ] + + @staticmethod + def run() -> dict: + """Run the section wizard.""" + click.echo("\n=== Section Configuration ===") + click.echo("Select which sections to include in your README:\n") + + sections = {} + for section_key, section_name in SectionWizard.SECTION_OPTIONS: + include = click.confirm(f"Include {section_name}?", default=True) + sections[section_key] = include + + click.echo("\nSection order (default order used). You can reorder by editing the config file.") + return sections + + +class ContentWizard: + """Wizard for manual overrides of auto-detected values.""" + + @staticmethod + def run(project: Project) -> Project: + """Run the content wizard.""" + click.echo("\n=== Content Customization ===") + click.echo("You can override any auto-detected values below. Leave blank to keep auto-detected values.\n") + + project.installation_steps = ContentWizard._edit_list( + "installation steps", + project.installation_steps or ["pip install -e ."], + ) + + project.usage_examples = ContentWizard._edit_list( + "usage examples", + project.usage_examples or ["# See the docs"], + ) + + project.features = ContentWizard._edit_list( + "features", + project.features or [], + ) + + return project + + @staticmethod + def _edit_list(prompt_name: str, current_list: list[str]) -> list[str]: + """Edit a list of strings.""" + click.echo(f"\nCurrent {prompt_name}:") + for i, item in enumerate(current_list, 1): + click.echo(f" {i}. {item}") + + add_new = click.confirm(f"Add new {prompt_name}?", default=False) + if not add_new: + return current_list + + new_list = current_list[:] + while True: + new_item = click.prompt(f" Enter {prompt_name} (or leave blank to finish)", default="", show_default=False) + if not new_item: + break + new_list.append(new_item) + + return new_list if new_list else current_list + + +def run_wizard(project: Project) -> Project: + """Run the complete interactive wizard.""" + click.echo("=== Auto README Generator - Interactive Mode ===\n") + + project = ProjectInfoWizard.run(project) + + project.custom_sections["section_config"] = SectionWizard.run() + + project = ContentWizard.run(project) + + click.echo("\n=== Wizard Complete ===") + click.echo("Your README will be generated with the provided information.") + + return project