Skip to content

Conversation

@httpdss
Copy link
Owner

@httpdss httpdss commented Nov 5, 2025

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 OpenAI
  • STRUCTKIT_INPUT_STORE - Set input store path for template variables (default: /tmp/structkit/input.json)
  • STRUCTKIT_BACKUP_PATH - Set default backup location

Medium 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

  • Updated STRUCTKIT_STRUCTURES_PATH help text in all relevant commands
  • Added environment variable hints to help text for each argument

Implementation Details

  • Precedence: CLI arguments > Environment variables > Built-in defaults
  • Backward Compatible: All existing code continues to work without changes
  • Documentation: Comprehensive guide included with examples for Docker, CI/CD pipelines

Testing

  • Added 29 comprehensive tests covering all environment variables
  • All existing tests pass (148 total)
  • Tests verify precedence rules and edge cases

Files Changed

  • structkit/commands/generate.py - Added environment variable support
  • structkit/commands/generate_schema.py - Updated help text
  • structkit/commands/info.py - Updated help text
  • structkit/commands/list.py - Updated help text
  • tests/test_commands.py - Updated test for new help text
  • tests/test_env_var_cli_args.py - New comprehensive test file (29 tests)
  • docs/environment-variables.md - New documentation

Closes

#123

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
@httpdss httpdss requested a review from Copilot November 5, 2025 01:22
Copy link

Copilot AI left a 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

Comment on lines 244 to 246
environment:
- STRUCTKIT_NON_INTERACTIVE: "true"
- STRUCTKIT_FILE_STRATEGY: "backup"
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
environment:
- STRUCTKIT_NON_INTERACTIVE: "true"
- STRUCTKIT_FILE_STRATEGY: "backup"
variables:
STRUCTKIT_NON_INTERACTIVE: "true"
STRUCTKIT_FILE_STRATEGY: "backup"

Copilot uses AI. Check for mistakes.
Comment on lines 275 to 277
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
Copy link

Copilot AI Nov 5, 2025

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).

Suggested change
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)

Copilot uses AI. Check for mistakes.
- 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
@httpdss httpdss added enhancement New feature or request minor labels Nov 5, 2025
@httpdss httpdss marked this pull request as ready for review November 5, 2025 02:42
@httpdss httpdss merged commit a9e4d26 into main Nov 5, 2025
3 checks passed
@httpdss httpdss deleted the feat/env-var-support-123 branch November 5, 2025 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants