Skip to content

My-Own-Working-Space/Design-Pattern-Cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dp-gen: Design Pattern Code Scaffolder

A simple CLI tool to generate boilerplate code for GoF Design Patterns.

Installation

Local Usage

  1. Clone this repository.
  2. Install dependencies:
    pip install -r requirements.txt

Global Usage (Recommended)

To run dp-gen from anywhere:

  1. Navigate to the project directory.
  2. Install in editable mode (add --break-system-packages if on Linux and not in a venv):
    pip install -e . --break-system-packages

Now you can just type dp-gen in any terminal!

Usage

Generate a design pattern boilerplate:

dp-gen make strategy --lang csharp

Generate a pattern with a custom name:

dp-gen make strategy Payment --lang csharp

Output directory:

python3 dp_gen.py make factory MyFactory --lang csharp --out ./output

Supported Patterns

  • strategy (C#, Python)
  • factory (C#)
  • observer (C#)
  • singleton (C#)
  • decorator (C#)

Adding More Templates

Add your Jinja2 templates to templates/<language>/<pattern>/. Use {{ name }} for the custom name provided by the user.

About

A CLI tool to generate boilerplate code for GoF Design Patterns in multiple languages.

Topics

Resources

License

Stars

Watchers

Forks

Contributors