Skip to content

Conversation

@httpdss
Copy link
Owner

@httpdss httpdss commented Sep 22, 2025

Description

This PR implements the feature requested in issue #116 to display variable descriptions in interactive mode prompts, enhancing the user experience when generating project structures.

Changes Made

Core Implementation

  • Modified struct_module/template_renderer.py: Updated the prompt_for_missing_vars method to display variable descriptions during interactive prompts
  • Added support for both description and help fields for backward compatibility
  • Descriptions are displayed on a separate line with proper indentation for clarity
  • Only displays descriptions when they exist in the variable configuration

Testing

  • Added comprehensive test: test_prompt_with_description_display() in tests/test_template_renderer.py
  • Tests cover all scenarios:
    • Variables with description field
    • Variables with enum options and descriptions
    • Variables with legacy help field
    • Variables without descriptions (ensuring no description is shown)
  • All existing tests continue to pass

Documentation

  • Updated docs/template-variables.md: Added explanation of the new description display feature
  • Included examples of how prompts appear with descriptions
  • Documented support for both description and help fields

Example Output

Before (without descriptions)

❓ Enter value for project_name [MyProject]: 
❓ Enter value for environment [dev] (1) dev, (2) staging, (3) prod: 

After (with descriptions)

❓ Enter value for project_name [MyProject]: 
   Description: The name of your project
❓ Enter value for environment [dev] (1) dev, (2) staging, (3) prod: 
   Description: Target deployment environment

Backward Compatibility

Fully backward compatible

  • Variables without descriptions work exactly as before
  • Supports legacy help field in addition to description
  • No breaking changes to existing functionality
  • All existing tests pass

Benefits

  • Improved UX: Users can understand what each variable represents without checking the YAML file
  • Self-documenting: Configurations become more user-friendly
  • Flexible: Works with both regular variables and enum-based selections
  • Clean: Only displays descriptions when available, maintaining clean prompts otherwise

Testing

# Run all template renderer tests
pytest tests/test_template_renderer.py -v

# Run specific test for this feature
pytest tests/test_template_renderer.py::test_prompt_with_description_display -v

Closes #116

- Add support for displaying variable descriptions in interactive prompts
- Support both 'description' and 'help' fields for backward compatibility
- Display descriptions only when available, maintaining clean prompts otherwise
- Add comprehensive tests for the new functionality
- Update documentation to explain the new feature

Closes #116
@codecov
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.70%. Comparing base (0c902a6) to head (4dce343).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #117      +/-   ##
==========================================
+ Coverage   68.06%   68.70%   +0.63%     
==========================================
  Files          20       20              
  Lines        1522     1553      +31     
  Branches      269      279      +10     
==========================================
+ Hits         1036     1067      +31     
  Misses        411      411              
  Partials       75       75              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Replace basic description display with clean Option 4 format
- Add contextual icons based on variable names and types
- Implement cleaner two-line format for variables with descriptions
- Maintain compact inline format for variables without descriptions
- Add comprehensive test coverage for icon selection logic
- Update documentation with new formatting examples

Icons included:
🚀 Project/app names | 🌍 Environment vars | 🔌 Network/ports
🗄️ Database configs | ⚡ Boolean toggles | 🔐 Auth/secrets
🏷️ Versions/tags | 📁 Paths/directories | 🔧 General vars
- Use ANSI escape codes to make variable names bold in interactive prompts
- Improves readability and visual hierarchy of prompts
- Update test assertions to match new bold formatting
- Update documentation to mention bold variable names
- All tests passing with new formatting
@httpdss httpdss added enhancement New feature or request minor labels Sep 22, 2025
@httpdss httpdss merged commit 005ea60 into main Sep 23, 2025
5 checks passed
@httpdss httpdss deleted the feature/display-variable-descriptions-116 branch September 23, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display variable descriptions in interactive mode prompts

2 participants