saving the API key correctly for windows PowerShell #940
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix API key detection and saving for PowerShell on Windows
Problem
On Windows PowerShell,
codeflash initsaved the API key tocodeflash_env.batusing CMD syntax (set CODEFLASH_API_KEY=...). PowerShell doesn't execute.batfiles automatically, so the key wasn't detected on subsequent runs. Users had to manually set$env:CODEFLASH_API_KEYeach session.Solution
codeflash_env.ps1with PowerShell syntax ($env:CODEFLASH_API_KEY = "...") when in PowerShellcodeflash_env.batwith CMD syntax when in CMD.ps1and.batfor compatibility. codeflash_env.ps1for PowerShell,call codeflash_env.batfor CMD)Changes
is_powershell()detection usingPSModulePath,COMSPEC, andTERM_PROGRAMsave_api_key_to_rc()to use the correct file format based on shell typeread_api_key_from_shell_config()to check both PowerShell and CMD filescmd_init.pyto use PowerShell syntax when appropriateThe API key is now saved and detected correctly in PowerShell sessions.