Skip to content

Conversation

Copy link

Copilot AI commented Nov 28, 2025

Adds support for resolving environment variables in @Option default values using $(ENV_VAR_NAME) syntax.

Changes

  • ProcessedOption.java: Resolve environment variables when default values are used (at usage time)

    • Pattern $(ENV_VAR_NAME) is replaced with System.getenv("ENV_VAR_NAME")
    • If env var is not set, original value is preserved
    • Empty syntax $() is ignored
    • The stored defaultValues are never modified; resolution happens when values are analyzed
  • EnvironmentVariableDefaultValueTest.java: 6 tests covering resolution, missing vars, empty syntax, and annotation-based usage

Usage

@Option(defaultValue = "$(MY_ENV_VALUE)")
private String configPath;

When the option is not provided by the user, aesh resolves $(MY_ENV_VALUE) to the environment variable's value when the default value is being used.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for environment variables in @option</issue_title>
<issue_description>If an Option is set with a defaultValue like: @Option(defaultValue="$(MY_ENV_VALUE)") aesh should try to get the value from the environment variable and set it to the default value.</issue_description>

<agent_instructions>The pr should also provide a test where it verifies that an environment variable is read and it's value put into the Option.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Nov 28, 2025
Copilot AI changed the title [WIP] Add support for environment variables in @Option Add support for environment variables in @Option defaultValue Nov 28, 2025
Copilot AI requested a review from stalep November 28, 2025 15:26
Copilot finished work on behalf of stalep November 28, 2025 15:26
@stalep stalep marked this pull request as ready for review November 28, 2025 15:40
Copy link
Member

@stalep stalep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of changing defaultValues, we should instead analyze the value of the defaultValue. If it matches an environment variable pattern it should replace it with the value found.

@stalep
Copy link
Member

stalep commented Nov 29, 2025

@copilot can you rewrite the pr based on the previous comment?

Copy link
Author

Copilot AI commented Nov 29, 2025

@copilot can you rewrite the pr based on the previous comment?

Rewritten in commit f17a428. The environment variable resolution now happens in ProcessedOption.resolveEnvironmentVariable() when the default value is actually used (in injectValueIntoField()), rather than modifying defaultValues in ProcessedOptionBuilder. The stored defaultValues remain unchanged.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.puppycrawl.com
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/aesh/.codeql-scratch/dbs/java/working/files-to-index173699748552659404.list --sourceArchiveDir=/home/REDACTED/work/aesh/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/aesh/.codeql-scratch/dbs/java/trap/java (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from stalep November 29, 2025 12:52
Copilot finished work on behalf of stalep November 29, 2025 12:52
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.

Add support for environment variables in @Option

2 participants