Skip to content

Add env sync CLI to export indexed paths as environment variables and document pipx installation - #2

Merged
a584-droid merged 1 commit into
mainfrom
codex/fix-pip-install-e-installation-issue
Mar 12, 2026
Merged

Add env sync CLI to export indexed paths as environment variables and document pipx installation#2
a584-droid merged 1 commit into
mainfrom
codex/fix-pip-install-e-installation-issue

Conversation

@a584-droid

Copy link
Copy Markdown
Owner

Motivation

  • Provide a way to export index entries as environment variables and manage a marked block in env files.
  • Allow easy global installation instructions via pipx so pathi can be used outside a venv.

Description

  • Add env sync subcommand to the CLI with options --file, --source, --normalize, --rebuild, and --print-only and wire it to cmd_env_sync in pathindex/cli.py.
  • Implement normalize_env_name, is_env_name, and replace_managed_block helpers and define managed block markers MANAGED_ENV_BEGIN/MANAGED_ENV_END to safely replace a managed block in target files.
  • cmd_env_sync collects 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.
  • Extend README.md with pipx installation instructions and usage examples for env sync and exporting the managed block to files or printing it.

Testing

  • No automated tests were added or run for this change.

Codex Task

@a584-droid
a584-droid merged commit a1131d1 into main Mar 12, 2026
0 of 3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread pathindex/cli.py

lines = [MANAGED_ENV_BEGIN]
for key in sorted(out):
lines.append(f'{key}="{out[key]}"')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread pathindex/cli.py
target.write_text(updated, encoding="utf-8")
print(f"Updated {target}")

print(f"Exported {len(out)} variables")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant