update
This commit is contained in:
+32
-27
@@ -75,19 +75,19 @@ class _CommandDependencies:
|
||||
self._plugins[norm_name] = plugin
|
||||
return plugin
|
||||
|
||||
def get_plugin_with_capability(self, name: str, capability: str) -> Optional[Any]:
|
||||
"""Cached plugin lookup with capability check."""
|
||||
from PluginCore.registry import get_plugin_with_capability
|
||||
def get_plugin_for_cmdlet(self, name: str, cmdlet_name: str) -> Optional[Any]:
|
||||
"""Cached plugin lookup with explicit cmdlet support check."""
|
||||
from PluginCore.registry import get_plugin_for_cmdlet
|
||||
|
||||
norm_name = str(name or "").strip().lower()
|
||||
if not norm_name:
|
||||
return None
|
||||
|
||||
cache_key = f"{norm_name}#{capability}"
|
||||
cache_key = f"{norm_name}#{cmdlet_name}"
|
||||
if cache_key in self._plugins:
|
||||
return self._plugins[cache_key]
|
||||
|
||||
plugin = get_plugin_with_capability(norm_name, capability, self.config)
|
||||
plugin = get_plugin_for_cmdlet(norm_name, cmdlet_name, self.config)
|
||||
self._plugins[cache_key] = plugin
|
||||
return plugin
|
||||
|
||||
@@ -1512,6 +1512,8 @@ class Add_File(Cmdlet):
|
||||
args: Sequence[str],
|
||||
config: Optional[Dict[str, Any]] = None,
|
||||
) -> Optional[str]:
|
||||
from PluginCore.registry import PLUGIN_REGISTRY
|
||||
|
||||
cfg = config if isinstance(config, dict) else {}
|
||||
|
||||
if Add_File._uses_legacy_path_flag(args):
|
||||
@@ -1556,17 +1558,20 @@ class Add_File(Cmdlet):
|
||||
|
||||
normalized_plugin_name = Add_File._normalize_provider_key(plugin_name)
|
||||
if normalized_plugin_name:
|
||||
upload_plugin = deps.get_plugin_with_capability(normalized_plugin_name, "upload")
|
||||
upload_plugin = deps.get_plugin_for_cmdlet(normalized_plugin_name, "add-file")
|
||||
if upload_plugin is None:
|
||||
plugin_exists = deps.get_plugin(normalized_plugin_name) is not None
|
||||
if plugin_exists:
|
||||
if normalized_plugin_name == "loc":
|
||||
plugin_info = PLUGIN_REGISTRY.get(normalized_plugin_name)
|
||||
if plugin_info is not None:
|
||||
canonical_plugin_name = str(plugin_info.canonical_name or normalized_plugin_name).strip().lower()
|
||||
if canonical_plugin_name == "loc":
|
||||
return (
|
||||
"Pipeline error: plugin 'loc' does not support add-file/upload. "
|
||||
"Pipeline error: plugin 'loc' does not support add-file. "
|
||||
"Use -plugin local -instance <name|path> for local export."
|
||||
)
|
||||
return f"Pipeline error: plugin '{normalized_plugin_name}' does not support add-file/upload."
|
||||
return f"Pipeline error: unknown upload plugin '{plugin_name}'."
|
||||
if "add-file" not in plugin_info.supported_cmdlets:
|
||||
return f"Pipeline error: plugin '{canonical_plugin_name}' does not support add-file."
|
||||
return f"Pipeline error: plugin '{canonical_plugin_name}' is not configured or not available for add-file."
|
||||
return f"Pipeline error: unknown add-file plugin '{plugin_name}'."
|
||||
|
||||
if normalized_plugin_name == "local":
|
||||
requested_local = str(plugin_instance or location or "").strip() or "<default>"
|
||||
@@ -1600,7 +1605,7 @@ class Add_File(Cmdlet):
|
||||
if deps is None:
|
||||
deps = _CommandDependencies(config)
|
||||
|
||||
file_provider = deps.get_plugin_with_capability(plugin_key, "upload")
|
||||
file_provider = deps.get_plugin_for_cmdlet(plugin_key, "add-file")
|
||||
if file_provider is None:
|
||||
return None
|
||||
|
||||
@@ -1656,7 +1661,7 @@ class Add_File(Cmdlet):
|
||||
if deps is None:
|
||||
deps = _CommandDependencies(config)
|
||||
|
||||
file_provider = deps.get_plugin_with_capability("local", "upload")
|
||||
file_provider = deps.get_plugin_for_cmdlet("local", "add-file")
|
||||
if file_provider is None:
|
||||
return None, None
|
||||
|
||||
@@ -2477,27 +2482,27 @@ class Add_File(Cmdlet):
|
||||
Any],
|
||||
delete_after: bool,
|
||||
) -> int:
|
||||
"""Handle uploading via an upload plugin (e.g. 0x0)."""
|
||||
"""Handle uploading via an add-file plugin (e.g. 0x0)."""
|
||||
from PluginCore.registry import (
|
||||
get_plugin_with_capability,
|
||||
list_plugin_names_with_capability,
|
||||
list_plugins_with_capability,
|
||||
PLUGIN_REGISTRY,
|
||||
get_plugin_for_cmdlet,
|
||||
list_plugins_for_cmdlet,
|
||||
)
|
||||
|
||||
try:
|
||||
file_provider = get_plugin_with_capability(plugin_name, "upload", config)
|
||||
file_provider = get_plugin_for_cmdlet(plugin_name, "add-file", config)
|
||||
if not file_provider:
|
||||
available_map = list_plugins_with_capability("upload", config)
|
||||
known_upload_plugins = set(list_plugin_names_with_capability("upload"))
|
||||
available_uploads = [name for name, enabled in available_map.items() if enabled and name in known_upload_plugins]
|
||||
available_map = list_plugins_for_cmdlet("add-file", config)
|
||||
available_add_plugins = [name for name, enabled in available_map.items() if enabled]
|
||||
requested_plugin_info = PLUGIN_REGISTRY.get(plugin_name)
|
||||
|
||||
if str(plugin_name or "").strip().lower() in known_upload_plugins:
|
||||
show_plugin_config_panel([plugin_name])
|
||||
if requested_plugin_info is not None and "add-file" in requested_plugin_info.supported_cmdlets:
|
||||
show_plugin_config_panel([requested_plugin_info.canonical_name])
|
||||
else:
|
||||
log(f"Upload plugin '{plugin_name}' is not available or does not support upload", file=sys.stderr)
|
||||
log(f"Add-file plugin '{plugin_name}' is not available or does not support add-file", file=sys.stderr)
|
||||
|
||||
if available_uploads:
|
||||
show_available_plugins_panel(sorted(available_uploads))
|
||||
if available_add_plugins:
|
||||
show_available_plugins_panel(sorted(available_add_plugins))
|
||||
return 1
|
||||
|
||||
upload_kwargs: Dict[str, Any] = {
|
||||
|
||||
@@ -15,7 +15,7 @@ from urllib.parse import urlparse, parse_qs, unquote, urljoin
|
||||
|
||||
from SYS.logger import log, debug, debug_panel
|
||||
from SYS.payload_builders import build_file_result_payload, normalize_file_extension
|
||||
from PluginCore.registry import get_plugin_with_capability, list_plugins_with_capability
|
||||
from PluginCore.registry import get_plugin_for_cmdlet, list_plugins_for_cmdlet
|
||||
from SYS.rich_display import (
|
||||
show_plugin_config_panel,
|
||||
show_store_config_panel,
|
||||
@@ -1478,7 +1478,7 @@ class search_file(Cmdlet):
|
||||
log("Error: search-file -plugin requires both plugin and query", file=sys.stderr)
|
||||
log(f"Usage: {self.usage}", file=sys.stderr)
|
||||
|
||||
providers_map = list_plugins_with_capability("search", config)
|
||||
providers_map = list_plugins_for_cmdlet("search-file", config)
|
||||
available = [n for n, a in providers_map.items() if a]
|
||||
unconfigured = [n for n, a in providers_map.items() if not a]
|
||||
|
||||
@@ -1499,8 +1499,10 @@ class search_file(Cmdlet):
|
||||
if hasattr(ctx_mod, "get_pipeline_state"):
|
||||
progress = ctx_mod.get_pipeline_state().live_progress
|
||||
|
||||
provider = get_plugin_with_capability(plugin_name, "search", config)
|
||||
if not provider:
|
||||
providers_map = list_plugins_for_cmdlet("search-file", config)
|
||||
provider = get_plugin_for_cmdlet(plugin_name, "search-file", config)
|
||||
resolved_plugin_name = str(getattr(provider, "name", "") or plugin_name).strip().lower()
|
||||
if not provider or not providers_map.get(resolved_plugin_name, False):
|
||||
if progress:
|
||||
try:
|
||||
progress.stop()
|
||||
@@ -1509,7 +1511,6 @@ class search_file(Cmdlet):
|
||||
|
||||
show_plugin_config_panel([plugin_name])
|
||||
|
||||
providers_map = list_plugins_with_capability("search", config)
|
||||
available = [n for n, a in providers_map.items() if a]
|
||||
if available:
|
||||
show_available_plugins_panel(available)
|
||||
|
||||
Reference in New Issue
Block a user