Skip to content

envSwitch v0.1.3

Choose a tag to compare

@dacj4n dacj4n released this 18 May 09:54
· 31 commits to main since this release

v0.1.3 (2026-05-18)

Changed — Architecture: shell function → precmd hook + env.sh

Removed the envswitch() shell function wrapper entirely and replaced it with a clean precmd hook architecture:

  • cover / uncover / auto no longer output export statements to stdout. They write ~/.envswitch/state/env.sh instead.
  • Shell init block now uses a precmd hook (zsh) / PROMPT_COMMAND (bash) that sources env.sh on every prompt.
  • Environment variables (JAVA_HOME, GOROOT, etc.) refresh automatically on the next prompt after a cover operation.
  • which envswitch now returns only the binary path — no more shell function pollution.
  • envswitch init writes .zshrc/.bashrc for new terminals, and prints a hint to source ~/.envswitch/init.sh for immediate effect in the current terminal.
  • envswitch uninit removes the init block and prints cleanup instructions for the current shell session.
  • load-globals is no longer called by the init block (replaced by direct source env.sh at startup).

Added — GUI: CLI init detection + Doctor diagnostics

  • cover_module now checks that the envSwitch CLI binary is available (via PATH search) and that shell integration is initialized before allowing cover operations. If not, a clear error message is shown.
  • Doctor page adds two new diagnostic checks:
    • envSwitch CLI available — verifies the CLI binary exists in PATH (not the GUI app bundle).
    • Shell integration initialized — checks .zshrc/.bashrc for the init block.

Fixed — CLI path detection

  • check_init_status() now finds the real CLI binary by searching PATH (equivalent to which envswitch) and common install locations (~/.cargo/bin/, /usr/local/bin/, /opt/homebrew/bin/), instead of returning the GUI app bundle path.

Fixed — Build warnings

  • Suppressed dead_code warnings on library items that are consumed by the GUI crate but unreferenced by the CLI binary target.

v0.1.3 (2026-05-18)

变更 — 架构重构:shell function → precmd hook + env.sh

彻底移除 envswitch() shell function 包装,改为干净的 precmd hook 架构:

  • cover / uncover / auto 不再向 stdout 输出 export 语句,改为写入 ~/.envswitch/state/env.sh。
  • Shell init block 使用 precmd hook(zsh)/ PROMPT_COMMAND(bash),在每个提示符自动 source env.sh。
  • JAVA_HOME、GOROOT 等环境变量在 cover 操作后的下一次提示符自动刷新。
  • which envswitch 现在只返回 binary 路径 — 不再有 shell function 污染。
  • envswitch init 为新终端写入 .zshrc/.bashrc,并提示 source ~/.envswitch/init.sh 使当前终端立即生效。
  • envswitch uninit 移除 init block 并打印当前 shell 会话清理指令。
  • load-globals 不再被 init block 调用(改为启动时直接 source env.sh)。

新增 — GUI:CLI 初始化检测 + 诊断增强

  • cover_module 在允许 cover 操作前检查 envSwitch CLI 二进制是否可用(通过 PATH 搜索)以及 Shell 集成是否已初始化。未初始化时显示明确错误提示。
  • 诊断页面新增两项检查:
    • envSwitch 命令行可用 — 验证 CLI 二进制在 PATH 中存在(而非 GUI app bundle 路径)。
    • Shell 集成已初始化 — 检查 .zshrc/.bashrc 中的 init block。

修复 — CLI 路径检测

  • check_init_status() 现在通过搜索 PATH(等同于 which envswitch)和常见安装位置(~/.cargo/bin/、/usr/local/bin/、/opt/homebrew/bin/)来查找真正的 CLI 二进制,而非返回 GUI app bundle 路径。

修复 — 编译警告

  • 对仅被 GUI crate 引用、未被 CLI binary target 使用的库项添加了 #[allow(dead_code)],消除编译警告。

Full Changelog: v0.1.2...v0.1.3