|
| 1 | +<!-- > |
| 2 | +
|
| 3 | +# Struct |
| 4 | +
|
| 5 | + |
| 6 | +
|
| 7 | +Automated Project Structure Generator |
| 8 | +
|
| 9 | +<!-- end_slide --> |
| 10 | + |
| 11 | +# What is Struct? |
| 12 | + |
| 13 | +Struct automates project structure creation from YAML configurations. |
| 14 | + |
| 15 | +- YAML-based configurations for reproducible scaffolding |
| 16 | +- Jinja2 templating and interactive prompts for dynamic content |
| 17 | +- Remote content sources (GitHub, HTTP/HTTPS, S3, GCS) |
| 18 | +- Smart file handling (overwrite, skip, append, rename, backup) |
| 19 | +- Hooks (pre/post) to automate tasks around generation |
| 20 | +- Dry-run and diff preview before applying changes |
| 21 | +- Validation and JSON schema generation |
| 22 | +- MCP (Model Context Protocol) integration |
| 23 | + |
| 24 | +<!-- end_slide --> |
| 25 | + |
| 26 | +# Install |
| 27 | + |
| 28 | +Option 1 — pip (from GitHub): |
| 29 | + |
| 30 | +```sh |
| 31 | +pip install git+https://github.com/httpdss/struct.git |
| 32 | +``` |
| 33 | + |
| 34 | +Option 2 — Docker: |
| 35 | + |
| 36 | +```sh |
| 37 | +docker run -v $(pwd):/workdir ghcr.io/httpdss/struct:main generate my-config.yaml ./output |
| 38 | +``` |
| 39 | + |
| 40 | +Option 3 — From source with venv: |
| 41 | + |
| 42 | +```sh |
| 43 | +python -m venv .venv |
| 44 | +source .venv/bin/activate |
| 45 | +pip install -U pip |
| 46 | +pip install . |
| 47 | +``` |
| 48 | + |
| 49 | +<!-- end_slide --> |
| 50 | + |
| 51 | +# Basic Commands |
| 52 | + |
| 53 | +- struct list — List available structures |
| 54 | +- struct generate — Generate a project from a structure or YAML file |
| 55 | +- struct validate — Validate a YAML configuration |
| 56 | +- struct generate-schema — Emit JSON schema for available structures |
| 57 | +- struct init — Create a minimal .struct.yaml in a directory |
| 58 | +- struct info — Show details about a structure definition |
| 59 | +- struct completion install — Install shell completions |
| 60 | +- struct mcp --server — Start MCP server |
| 61 | + |
| 62 | +```sh |
| 63 | +struct --help |
| 64 | +``` |
| 65 | + |
| 66 | +<!-- end_slide --> |
| 67 | + |
| 68 | +# List Structures |
| 69 | + |
| 70 | +See all available structures: |
| 71 | + |
| 72 | +```sh |
| 73 | +struct list |
| 74 | +``` |
| 75 | + |
| 76 | +Include custom structure directories: |
| 77 | + |
| 78 | +```sh |
| 79 | +struct list -s ~/custom-structures |
| 80 | +``` |
| 81 | + |
| 82 | +Tip (with shell completion enabled): |
| 83 | + |
| 84 | +```sh |
| 85 | +struct generate <Tab> # shows available structures |
| 86 | +``` |
| 87 | + |
| 88 | +<!-- end_slide --> |
| 89 | + |
| 90 | +# Generate: Quick Start |
| 91 | + |
| 92 | +Use defaults (.struct.yaml in current dir, generate into current dir): |
| 93 | + |
| 94 | +```sh |
| 95 | +struct generate |
| 96 | +``` |
| 97 | + |
| 98 | +Generate a Terraform module (example): |
| 99 | + |
| 100 | +```sh |
| 101 | +struct generate terraform/modules/generic ./my-terraform-module |
| 102 | +``` |
| 103 | + |
| 104 | +Generate from a YAML file: |
| 105 | + |
| 106 | +```sh |
| 107 | +struct generate my-config.yaml ./output |
| 108 | +# or |
| 109 | +struct generate file://my-config.yaml ./output |
| 110 | +``` |
| 111 | + |
| 112 | +<!-- end_slide --> |
| 113 | + |
| 114 | +# Generate: Variables & Paths |
| 115 | + |
| 116 | +Pass template variables: |
| 117 | + |
| 118 | +```sh |
| 119 | +struct generate -v "project_name=MyApp,author=John Doe" file://structure.yaml ./output |
| 120 | +``` |
| 121 | + |
| 122 | +Use additional custom structures path: |
| 123 | + |
| 124 | +```sh |
| 125 | +struct generate -s ~/custom-structures python-api ./my-api |
| 126 | +``` |
| 127 | + |
| 128 | +<!-- end_slide --> |
| 129 | + |
| 130 | +# Generate: Dry Run & Diff |
| 131 | + |
| 132 | +Preview without creating files and show diffs: |
| 133 | + |
| 134 | +```sh |
| 135 | +struct generate --dry-run --diff file://structure.yaml ./output |
| 136 | +``` |
| 137 | + |
| 138 | +Other helpful options: |
| 139 | +- --log=DEBUG |
| 140 | +- --mappings-file path.yaml (can be repeated) |
| 141 | +- --output {console,file} |
| 142 | + |
| 143 | +<!-- end_slide --> |
| 144 | + |
| 145 | +# Handling Existing Files |
| 146 | + |
| 147 | +Skip existing files: |
| 148 | + |
| 149 | +```sh |
| 150 | +struct generate -f skip file://structure.yaml ./output |
| 151 | +``` |
| 152 | + |
| 153 | +Backup before overwriting: |
| 154 | + |
| 155 | +```sh |
| 156 | +struct generate -f backup -b ./backup file://structure.yaml ./output |
| 157 | +``` |
| 158 | + |
| 159 | +Other strategies: overwrite, append, rename |
| 160 | + |
| 161 | +<!-- end_slide --> |
| 162 | + |
| 163 | +# Multiple Use Cases |
| 164 | + |
| 165 | +- Infrastructure as Code: Terraform modules, Kubernetes manifests |
| 166 | +- Application Scaffolding: microservices, APIs, frontends |
| 167 | +- DevOps Automation: CI/CD pipelines, configuration management |
| 168 | +- Documentation: consistent project docs and compliance templates |
| 169 | + |
| 170 | +<!-- end_slide --> |
| 171 | + |
| 172 | +# Extras |
| 173 | + |
| 174 | +Initialize a starter configuration: |
| 175 | + |
| 176 | +```sh |
| 177 | +struct init |
| 178 | +``` |
| 179 | + |
| 180 | +Validate a configuration: |
| 181 | + |
| 182 | +```sh |
| 183 | +struct validate my-structure.yaml |
| 184 | +``` |
| 185 | + |
| 186 | +Generate JSON schema: |
| 187 | + |
| 188 | +```sh |
| 189 | +struct generate-schema -o schema.json |
| 190 | +``` |
| 191 | + |
| 192 | +Shell completion (auto-detect shell): |
| 193 | + |
| 194 | +```sh |
| 195 | +struct completion install |
| 196 | +``` |
| 197 | + |
| 198 | +MCP integration: |
| 199 | + |
| 200 | +```sh |
| 201 | +struct mcp --server |
| 202 | +``` |
| 203 | + |
| 204 | +<!-- end_slide --> |
| 205 | + |
| 206 | +# End |
0 commit comments