Skip to content

Refactor config loading to use runtime parsing#10

Merged
guodong-sq merged 3 commits intomainfrom
runtime-config-loading
Feb 9, 2026
Merged

Refactor config loading to use runtime parsing#10
guodong-sq merged 3 commits intomainfrom
runtime-config-loading

Conversation

@guodong-sq
Copy link
Copy Markdown
Collaborator

@guodong-sq guodong-sq commented Feb 9, 2026

Summary

  • Eliminates shell reload requirement after context switching
  • Configuration is now parsed at runtime from ~/.wt/current instead of being sourced
  • Adds wt_read_config() function for safe config parsing without shell sourcing
  • Updates ~/.wt/current file format to include full config (maintains backward compatibility)

Test plan

  • Fresh install test: ./install.sh creates proper current file format
  • Context switching: wt context <name> takes effect immediately without shell reload
  • Environment override: WT_MAIN_REPO_ROOT=/tmp/test wt list uses override
  • Tab completion works after context switch
  • Old format migration: existing installations with old current file format still work

🤖 Generated with Claude Code

This eliminates the need to reload the shell after context switching.
Previously, `wt context` required re-sourcing wt-common to pick up new
context variables. Now configuration is parsed at runtime from
~/.wt/current, allowing immediate effect.

Changes:
- Add wt_read_config() that parses config files without sourcing
- Update ~/.wt/current format to include full config (not just name)
- Add WT_CONTEXT_NAME variable to track current context
- Remove re-source logic from wt.sh context handler
- Add wt_read_config() calls to completion and help functions
- Maintain backward compatibility with old current file format

The new current file format:
  # Active context: java
  WT_CONTEXT_NAME="java"
  WT_MAIN_REPO_ROOT="..."
  ...

Environment variables still override config file values.
@guodong-sq guodong-sq force-pushed the runtime-config-loading branch from 00b3c98 to ae79d80 Compare February 9, 2026 05:27
@guodong-sq guodong-sq marked this pull request as ready for review February 9, 2026 05:53
@guodong-sq guodong-sq merged commit c9a749d into main Feb 9, 2026
1 check passed
@guodong-sq guodong-sq deleted the runtime-config-loading branch February 9, 2026 05:53
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.

1 participant