Add env sync CLI to export indexed paths as environment variables and document pipx installation - #2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70903452a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| lines = [MANAGED_ENV_BEGIN] | ||
| for key in sorted(out): | ||
| lines.append(f'{key}="{out[key]}"') |
There was a problem hiding this comment.
Escape env values before emitting assignments
The export line f'{key}="{out[key]}"' writes raw paths into quoted values without escaping, so any indexed path containing a double quote (valid on POSIX filesystems, e.g. an alias path like /tmp/a"b) produces an invalid assignment and breaks consumers of the generated block. Because env sync is meant to generate reusable environment-variable definitions, values should be escaped or serialized in a format that preserves arbitrary path characters.
Useful? React with 👍 / 👎.
| target.write_text(updated, encoding="utf-8") | ||
| print(f"Updated {target}") | ||
|
|
||
| print(f"Exported {len(out)} variables") |
There was a problem hiding this comment.
Honor --print-only by avoiding extra stdout lines
--print-only is documented and described as printing the managed block, but the command always prints Exported ... (and optionally skipped counts) afterward. This makes the output unsuitable for piping directly into env files or shell evaluation, because the trailing status text is not part of the managed block and can invalidate downstream parsing.
Useful? React with 👍 / 👎.
Motivation
pipxsopathican be used outside a venv.Description
env syncsubcommand to the CLI with options--file,--source,--normalize,--rebuild, and--print-onlyand wire it tocmd_env_syncinpathindex/cli.py.normalize_env_name,is_env_name, andreplace_managed_blockhelpers and define managed block markersMANAGED_ENV_BEGIN/MANAGED_ENV_ENDto safely replace a managed block in target files.cmd_env_synccollects indexed entries, optionally normalizes names, filters by source, skips invalid env names, prints or writes a managed block to the specified file, and reports counts of exported/skipped variables.README.mdwithpipxinstallation instructions and usage examples forenv syncand exporting the managed block to files or printing it.Testing
Codex Task