|
1 | 1 | # Command-Line Auto-Completion |
2 | 2 |
|
3 | | -This project uses [argcomplete](https://kislyuk.github.io/argcomplete/) to provide command-line auto-completion for the `struct` script. Follow these steps to enable auto-completion: |
| 3 | +STRUCT provides intelligent auto-completion for commands, options, and **structure names** using [argcomplete](https://kislyuk.github.io/argcomplete/). This makes discovering and using available structures much faster and more user-friendly. |
4 | 4 |
|
5 | | -## Installation |
| 5 | +!!! tip "New Feature: Structure Name Completion" |
| 6 | + STRUCT now automatically completes structure names when using `struct generate`, showing all 47+ available structures from both built-in and custom paths! |
| 7 | + |
| 8 | +## Quick Setup |
| 9 | + |
| 10 | +For most users, this simple setup will enable full completion: |
| 11 | + |
| 12 | +```sh |
| 13 | +# Install (if not already installed) |
| 14 | +pip install argcomplete |
| 15 | + |
| 16 | +# Enable completion for current session |
| 17 | +eval "$(register-python-argcomplete struct)" |
| 18 | + |
| 19 | +# Make permanent - add to your ~/.zshrc or ~/.bashrc |
| 20 | +echo 'eval "$(register-python-argcomplete struct)"' >> ~/.zshrc |
| 21 | +``` |
| 22 | + |
| 23 | +## Detailed Installation |
6 | 24 |
|
7 | 25 | ### 1. Install argcomplete |
8 | 26 |
|
9 | 27 | ```sh |
10 | 28 | pip install argcomplete |
11 | 29 | ``` |
12 | 30 |
|
13 | | -### 2. Enable Global Completion |
| 31 | +### 2. Enable Global Completion (Optional) |
14 | 32 |
|
15 | | -This step is usually done once per system: |
| 33 | +This step is optional but can be done once per system: |
16 | 34 |
|
17 | 35 | ```sh |
18 | 36 | activate-global-python-argcomplete |
@@ -59,15 +77,41 @@ source ~/.config/fish/config.fish |
59 | 77 |
|
60 | 78 | After completing the setup, you can use auto-completion by typing part of a command and pressing `Tab`: |
61 | 79 |
|
| 80 | +### Command Completion |
62 | 81 | ```sh |
63 | 82 | struct <Tab> |
64 | 83 | # Shows: generate, generate-schema, validate, info, list |
| 84 | +``` |
65 | 85 |
|
| 86 | +### Structure Name Completion ✨ |
| 87 | +```sh |
| 88 | +# Complete structure names - shows all available structures! |
66 | 89 | struct generate <Tab> |
67 | | -# Shows available structure names and options |
| 90 | +# Shows: ansible-playbook, docker-files, github/workflows/codeql, project/nodejs, etc. |
| 91 | + |
| 92 | +# Partial completion works too |
| 93 | +struct generate git<Tab> |
| 94 | +# Shows: git-hooks, github/workflows/codeql, github/templates, etc. |
68 | 95 |
|
| 96 | +# Works with nested structures |
| 97 | +struct generate github/<Tab> |
| 98 | +# Shows: github/workflows/codeql, github/templates, github/prompts/generic, etc. |
| 99 | +``` |
| 100 | + |
| 101 | +### Custom Structure Paths |
| 102 | +```sh |
| 103 | +# Completion works with custom structure paths |
| 104 | +struct generate --structures-path /custom/path <Tab> |
| 105 | +# Shows structures from both custom path and built-in structures |
| 106 | +``` |
| 107 | + |
| 108 | +### Option Completion |
| 109 | +```sh |
69 | 110 | struct generate --<Tab> |
70 | | -# Shows: --log, --dry-run, --backup, --file-strategy, etc. |
| 111 | +# Shows: --log, --dry-run, --backup, --file-strategy, --structures-path, etc. |
| 112 | + |
| 113 | +struct generate --log <Tab> |
| 114 | +# Shows: DEBUG, INFO, WARNING, ERROR, CRITICAL |
71 | 115 | ``` |
72 | 116 |
|
73 | 117 | ## Advanced Configuration |
@@ -180,32 +224,64 @@ eval "$(register-python-argcomplete struct-wrapper.sh)" |
180 | 224 |
|
181 | 225 | ## Supported Completions |
182 | 226 |
|
183 | | -STRUCT provides completion for: |
| 227 | +STRUCT provides intelligent completion for: |
184 | 228 |
|
185 | | -- **Commands**: `generate`, `validate`, `list`, etc. |
186 | | -- **Options**: `--log`, `--dry-run`, `--backup`, etc. |
187 | | -- **Structure names**: All available built-in and custom structures |
| 229 | +- **Commands**: `generate`, `validate`, `list`, `info`, `generate-schema` |
| 230 | +- **Options**: `--log`, `--dry-run`, `--backup`, `--file-strategy`, `--structures-path`, etc. |
| 231 | +- **Structure names**: All 47+ available built-in and custom structures |
| 232 | + - Built-in structures: `ansible-playbook`, `docker-files`, `helm-chart`, etc. |
| 233 | + - Nested structures: `github/workflows/codeql`, `project/nodejs`, `terraform/apps/generic`, etc. |
| 234 | + - Custom structures: From `--structures-path` directories |
188 | 235 | - **File paths**: Local files and directories |
189 | | -- **Enum values**: Log levels, file strategies, etc. |
| 236 | +- **Enum values**: Log levels (`DEBUG`, `INFO`, etc.), file strategies (`overwrite`, `skip`, etc.) |
| 237 | + |
| 238 | +## How Structure Completion Works |
| 239 | + |
| 240 | +The structure name completion feature: |
| 241 | + |
| 242 | +1. **Dynamically discovers** all available structure files (`.yaml` files) |
| 243 | +2. **Scans multiple locations**: |
| 244 | + - Built-in structures in `struct_module/contribs/` |
| 245 | + - Custom structures from `--structures-path` if specified |
| 246 | +3. **Returns clean names** without `.yaml` extensions |
| 247 | +4. **Supports nested directories** like `github/workflows/codeql` |
| 248 | +5. **Updates automatically** when new structures are added |
190 | 249 |
|
191 | 250 | ## Example Session |
192 | 251 |
|
193 | 252 | ```sh |
| 253 | +# Command completion |
194 | 254 | $ struct <Tab> |
195 | 255 | generate generate-schema info list validate |
196 | 256 |
|
| 257 | +# Structure name completion (NEW!) |
197 | 258 | $ struct generate <Tab> |
198 | | -configs/ docker-files project/ terraform/ |
199 | | - |
200 | | -$ struct generate terraform/<Tab> |
201 | | -terraform/app terraform/module |
202 | | - |
| 259 | +ansible-playbook configs/codeowners github/workflows/codeql project/nodejs |
| 260 | +chef-cookbook docker-files helm-chart terraform/apps/generic |
| 261 | +ci-cd-pipelines git-hooks kubernetes-manifests vagrant-files |
| 262 | + |
| 263 | +# Partial completion |
| 264 | +$ struct generate proj<Tab> |
| 265 | +project/custom-structures project/go project/nodejs project/ruby |
| 266 | +project/generic project/java project/python project/rust |
| 267 | + |
| 268 | +# Nested structure completion |
| 269 | +$ struct generate github/<Tab> |
| 270 | +github/chatmodes/plan github/prompts/react-form github/workflows/codeql |
| 271 | +github/instructions/generic github/prompts/security-api github/workflows/labeler |
| 272 | +github/prompts/generic github/workflows/pre-commit github/workflows/stale |
| 273 | + |
| 274 | +# Option completion |
203 | 275 | $ struct generate --<Tab> |
204 | 276 | --backup --dry-run --file-strategy --log |
205 | | ---log-file --mappings-file --structures-path |
| 277 | +--log-file --mappings-file --structures-path --vars |
206 | 278 |
|
| 279 | +# Enum value completion |
207 | 280 | $ struct generate --log <Tab> |
208 | | -DEBUG ERROR INFO WARNING |
| 281 | +DEBUG ERROR INFO WARNING CRITICAL |
| 282 | + |
| 283 | +$ struct generate --file-strategy <Tab> |
| 284 | +append backup overwrite rename skip |
209 | 285 | ``` |
210 | 286 |
|
211 | 287 | This makes working with STRUCT much more efficient and user-friendly! |
0 commit comments