You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: variable discovery and validation improvements (#104)
Closes#94
- Defaults from environment variables via `env` or `default_from_env` in
variable schema.
- Type coercion: boolean, integer, float/number; string by default.
- Validation: enum, regex/pattern, min/max numeric bounds.
- Required handling: in non-interactive mode, missing required variables
raise a clear error.
- Tests added for env defaults and coercion/validation.
All tests pass (95).
Copy file name to clipboardExpand all lines: docs/file-handling.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ files:
68
68
69
69
## Remote File Protocols
70
70
71
-
STRUCT supports multiple protocols for fetching remote content:
71
+
STRUCT supports multiple protocols for fetching remote content (with caching and robust fallbacks):
72
72
73
73
### HTTP/HTTPS
74
74
@@ -80,6 +80,12 @@ files:
80
80
81
81
### GitHub Protocols
82
82
83
+
STRUCT optimizes single-file fetches from GitHub by preferring `raw.githubusercontent.com` when possible and falling back to `git clone/pull` if necessary. You can control behavior with environment variables:
84
+
85
+
- `STRUCT_HTTP_TIMEOUT`(seconds, default 10)
86
+
- `STRUCT_HTTP_RETRIES`(default 2)
87
+
- `STRUCT_DENY_NETWORK=1`to skip HTTP attempts and use git fallback directly.
Copy file name to clipboardExpand all lines: docs/template-variables.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,8 +78,47 @@ variables:
78
78
79
79
- `string`: Text values
80
80
- `integer`: Numeric values
81
+
- `number`: Floating-point values
81
82
- `boolean`: True/false values
82
83
84
+
### Validation and Defaults
85
+
86
+
Interactive enum selection: when a variable defines `enum` and you are in interactive mode, STRUCT will display numbered choices and accept either the number or the exact value. Press Enter to accept the default (if any).
87
+
88
+
Example prompt:
89
+
90
+
```
91
+
❓ Enter value for ENV [dev] (1) dev, (2) prod:
92
+
# Typing `2` selects `prod`, typing `prod` also works.
93
+
```
94
+
95
+
You can now enforce types and validations in your variables schema:
96
+
97
+
-`required: true` to require a value (non-interactive runs will error if missing)
98
+
-`enum: [...]` to restrict values to a set
99
+
-`regex`/`pattern` to validate string format
100
+
-`min`/`max` to bound numeric values
101
+
-`env` or `default_from_env` to set defaults from environment variables
0 commit comments