This commit is contained in:
2026-01-11 00:39:17 -08:00
parent 13caa8d5fa
commit 6eb02f22b5
9 changed files with 736 additions and 40 deletions

View File

@@ -104,10 +104,10 @@ def _register_native_commands() -> None:
pass
def ensure_cmdlet_modules_loaded() -> None:
def ensure_cmdlet_modules_loaded(force: bool = False) -> None:
global _MODULES_LOADED
if _MODULES_LOADED:
if _MODULES_LOADED and not force:
return
for mod_name in _iter_cmdlet_module_names():

View File

@@ -202,7 +202,8 @@ class SharedArgs:
)
@staticmethod
def get_store_choices(config: Optional[Dict[str, Any]] = None) -> List[str]:
@staticmethod
def get_store_choices(config: Optional[Dict[str, Any]] = None, force: bool = False) -> List[str]:
"""Get list of available store backend names.
This method returns the cached list of available backends from the most
@@ -210,7 +211,8 @@ class SharedArgs:
Users must restart to refresh the list if stores are enabled/disabled.
Args:
config: Ignored (kept for compatibility); uses cached startup result.
config: Optional config dict. Used if force=True or no cache exists.
force: If True, force a fresh check of the backends.
Returns:
List of backend names (e.g., ['default', 'test', 'home', 'work'])
@@ -219,23 +221,13 @@ class SharedArgs:
Example:
SharedArgs.STORE.choices = SharedArgs.get_store_choices(config)
"""
# Use the cached startup check result if available
if hasattr(SharedArgs, "_cached_available_stores"):
# Use the cached startup check result if available (unless force=True)
if not force and hasattr(SharedArgs, "_cached_available_stores"):
return SharedArgs._cached_available_stores or []
# Fallback to configured names if cache doesn't exist yet
# (This shouldn't happen in normal operation, but provides a safe fallback)
try:
from Store.registry import list_configured_backend_names
if config is None:
try:
from SYS.config import load_config
config = load_config()
except Exception:
return []
return list_configured_backend_names(config) or []
except Exception:
return []
# Refresh the cache
SharedArgs._refresh_store_choices_cache(config)
return SharedArgs._cached_available_stores or []
@staticmethod
def _refresh_store_choices_cache(config: Optional[Dict[str, Any]] = None) -> None: