-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add environment variable support for CLI arguments #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements environment variable support for additional CLI arguments to improve usability in CI/CD pipelines and containerized environments. High Priority Variables: - STRUCTKIT_GLOBAL_SYSTEM_PROMPT: Set global system prompt for OpenAI - STRUCTKIT_INPUT_STORE: Set input store path for template variables - STRUCTKIT_BACKUP_PATH: Set default backup location Medium Priority Variables: - STRUCTKIT_FILE_STRATEGY: Set default file handling strategy - STRUCTKIT_NON_INTERACTIVE: Enable/disable interactive mode - STRUCTKIT_OUTPUT_MODE: Set default output mode Shared Variables: - STRUCTKIT_STRUCTURES_PATH: Set custom structures path (updated help text) - STRUCTKIT_LOG_LEVEL: Control logging verbosity Changes: - Updated generate.py with environment variable support - Updated generate_schema.py, info.py, list.py with updated help text - CLI arguments take precedence over environment variables - Added 29 comprehensive tests for environment variable functionality - Created extensive documentation with examples Closes #123
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds environment variable support for CLI arguments to improve usability in CI/CD pipelines and containerized environments. The implementation allows users to set default values via environment variables while maintaining CLI argument precedence.
Key Changes:
- Added environment variable support for 6 CLI arguments in the generate command (global system prompt, input store, backup path, file strategy, non-interactive mode, output mode)
- Updated help text across all commands to indicate environment variable support for STRUCTKIT_STRUCTURES_PATH
- Created comprehensive documentation and test coverage (29 new tests)
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| structkit/commands/generate.py | Added environment variable defaults and updated help text for 6 arguments |
| structkit/commands/generate_schema.py | Updated help text and added environment variable default for structures-path |
| structkit/commands/info.py | Updated help text to indicate STRUCTKIT_STRUCTURES_PATH support |
| structkit/commands/list.py | Updated help text to indicate STRUCTKIT_STRUCTURES_PATH support |
| tests/test_commands.py | Updated test assertion to match new help text format |
| tests/test_env_var_cli_args.py | Added comprehensive test suite with 29 tests covering all environment variables |
| docs/environment-variables.md | Added complete documentation with examples for Docker and CI/CD usage |
docs/environment-variables.md
Outdated
| environment: | ||
| - STRUCTKIT_NON_INTERACTIVE: "true" | ||
| - STRUCTKIT_FILE_STRATEGY: "backup" |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GitLab CI YAML syntax is incorrect. Environment variables should be defined under 'variables:' key, not 'environment:'. The current syntax will cause a pipeline configuration error.
| environment: | |
| - STRUCTKIT_NON_INTERACTIVE: "true" | |
| - STRUCTKIT_FILE_STRATEGY: "backup" | |
| variables: | |
| STRUCTKIT_NON_INTERACTIVE: "true" | |
| STRUCTKIT_FILE_STRATEGY: "backup" |
docs/environment-variables.md
Outdated
| For `STRUCTKIT_NON_INTERACTIVE`, only `true`, `1`, and `yes` (case-insensitive) are recognized as true values. All other values are treated as false, including: | ||
| - `"true "` (with trailing space) | ||
| - `"True"` in mixed case |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement is contradictory. Line 161 shows that 'True' (with capital T) is tested and expected to work correctly in the parametrized test. The documentation should clarify that 'True' is actually recognized as a valid true value (case-insensitive matching is used).
| For `STRUCTKIT_NON_INTERACTIVE`, only `true`, `1`, and `yes` (case-insensitive) are recognized as true values. All other values are treated as false, including: | |
| - `"true "` (with trailing space) | |
| - `"True"` in mixed case | |
| For `STRUCTKIT_NON_INTERACTIVE`, only `true`, `1`, and `yes` (case-insensitive, e.g., `"True"`, `"TRUE"`, `"YeS"`) are recognized as true values. All other values are treated as false, including: | |
| - `"true "` (with trailing space) |
- Fix GitLab CI YAML syntax: Use 'variables:' instead of 'environment:' key - Clarify documentation: Case-insensitive means 'True', 'TRUE', etc. are valid - Remove misleading statement that 'True' in mixed case is NOT recognized - Add examples of valid case variations Addresses PR #125 review feedback from Copilot
- Remove GitLab CI example - Add basic GitHub Actions example - Add advanced GitHub Actions example with custom structures and step summary - Focus documentation on GitHub Actions as the primary CI/CD platform
Description
Implements environment variable support for additional CLI arguments to improve usability in CI/CD pipelines and containerized environments. This is a follow-up to #122.
Changes
High Priority Environment Variables
STRUCTKIT_GLOBAL_SYSTEM_PROMPT- Set global system prompt for OpenAISTRUCTKIT_INPUT_STORE- Set input store path for template variables (default:/tmp/structkit/input.json)STRUCTKIT_BACKUP_PATH- Set default backup locationMedium Priority Environment Variables
STRUCTKIT_FILE_STRATEGY- Set default file handling strategy (overwrite, skip, append, rename, backup)STRUCTKIT_NON_INTERACTIVE- Enable/disable interactive mode (recognizes: true, 1, yes)STRUCTKIT_OUTPUT_MODE- Set default output mode (console or file)Updated Help Text
STRUCTKIT_STRUCTURES_PATHhelp text in all relevant commandsImplementation Details
Testing
Files Changed
structkit/commands/generate.py- Added environment variable supportstructkit/commands/generate_schema.py- Updated help textstructkit/commands/info.py- Updated help textstructkit/commands/list.py- Updated help texttests/test_commands.py- Updated test for new help texttests/test_env_var_cli_args.py- New comprehensive test file (29 tests)docs/environment-variables.md- New documentationCloses
#123