Skip to content

feat: env fallback for unprovided options - #30

Merged
gen740 merged 6 commits into
mainfrom
feat/env-fallback
May 10, 2026
Merged

gen740 merged 6 commits into
mainfrom
feat/env-fallback

Conversation

@gen740

@gen740 gen740 commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add .env field to ArgParameter and ArgImpl to specify an environment variable name
  • After CLI token dispatch, apply_env_fallback() checks getenv() for each unprovided option that has .env set
  • Normal action pipeline (conversion + validation) runs on the env value, so type checking still applies
  • CLI values always take precedence over env
  • Env values satisfy required option checks
struct Args {
  cli::StringOption<"output"> output{{.env = "MYAPP_OUTPUT"}};
  cli::IntOption<"jobs">     jobs{{.presence = cli::required, .env = "MYAPP_JOBS"}};
};

🤖 Generated with Claude Code

gen740 and others added 6 commits May 10, 2026 23:14
…iables

Add .env field to ArgParameter and ArgImpl. After CLI token dispatch,
apply_env_fallback() iterates unprovided options with a non-empty env
name, calls getenv(), and runs the normal action pipeline so that
conversion and validation still apply. CLI values always take
precedence. Env values satisfy required-option checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SetEnvironmentVariableA only updates the OS environment block, not the
CRT's _environ table that _dupenv_s reads from. _putenv_s updates both.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gen740
gen740 force-pushed the feat/env-fallback branch from 30b0e4e to e088629 Compare May 10, 2026 14:45
@gen740
gen740 merged commit 41ffe50 into main May 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant