continuing refactor

This commit is contained in:
2026-05-03 21:20:05 -07:00
parent 77cab1bd27
commit 5534812426
50 changed files with 1004 additions and 428 deletions
+12 -18
View File
@@ -65,8 +65,8 @@ _BING_RESULT_ANCHOR_RE = re.compile(
r'<h2[^>]*>\s*<a[^>]+href="([^"]+)"[^>]*>(.*?)</a>',
flags=re.IGNORECASE | re.DOTALL,
)
_STORE_FILTER_RE = re.compile(r"\bstore:([^\s,]+)", flags=re.IGNORECASE)
_STORE_FILTER_REMOVE_RE = re.compile(r"\s*[,]?\s*store:[^\s,]+", flags=re.IGNORECASE)
_STORE_FILTER_RE = re.compile(r"\binstance:([^\s,]+)", flags=re.IGNORECASE)
_STORE_FILTER_REMOVE_RE = re.compile(r"\s*[,]?\s*instance:[^\s,]+", flags=re.IGNORECASE)
class _WorkerLogger:
@@ -169,15 +169,14 @@ class search_file(Cmdlet):
def __init__(self) -> None:
super().__init__(
name="search-file",
summary="Search configured store backends or search-capable plugins.",
usage="search-file [-query <query>] [-store BACKEND] [-instance NAME] [-limit N] [-plugin NAME]",
summary="Search configured instances or search-capable plugins.",
usage="search-file [-query <query>] [-instance NAME] [-limit N] [-plugin NAME]",
arg=[
CmdletArg(
"limit",
type="integer",
description="Limit results (default: 100)"
),
SharedArgs.STORE,
SharedArgs.INSTANCE,
SharedArgs.QUERY,
SharedArgs.PLUGIN,
@@ -189,17 +188,16 @@ class search_file(Cmdlet):
],
detail=[
"Search across configured store backends or plugin providers.",
"Use -store to target a specific store backend by name.",
"Use -instance to target a specific configured backend/instance by name.",
"Use -plugin with -instance to target a named provider config.",
"In plugin mode, -store <name> is kept as a compatibility alias for -instance <name>.",
"URL search: url:* (any URL) or url:<value> (URL substring)",
"Extension search: ext:<value> (e.g., ext:png)",
"Hydrus-style extension: system:filetype = png",
"Results include hash for downstream commands (get-file, add-tag, etc.)",
"Examples:",
"search-file -query foo # Search all storage backends",
"search-file -store home -query '*' # Search 'home' Hydrus instance",
"search-file -store home -query 'video' # Search 'home' Hydrus instance",
"search-file -instance home -query '*' # Search 'home' Hydrus instance",
"search-file -instance home -query 'video' # Search 'home' Hydrus instance",
"search-file -query 'hash:deadbeef...' # Search by SHA256 hash",
"search-file -query 'url:*' # Files that have any URL",
"search-file -query 'url:youtube.com' # Files whose URL contains substring",
@@ -291,7 +289,7 @@ class search_file(Cmdlet):
return None
# Avoid hijacking explicit local search DSL (url:, tag:, hash:, etc.).
local_markers = ("url:", "hash:", "tag:", "store:", "system:")
local_markers = ("url:", "hash:", "tag:", "instance:", "system:")
if any(marker in text.lower() for marker in local_markers):
return None
@@ -1741,10 +1739,6 @@ class search_file(Cmdlet):
f.lower()
for f in (flag_registry.get("query") or {"-query", "--query"})
}
store_flags = {
f.lower()
for f in (flag_registry.get("store") or {"-store", "--store"})
}
instance_flags = {
f.lower()
for f in (flag_registry.get("instance") or {"-instance", "--instance"})
@@ -1801,10 +1795,7 @@ class search_file(Cmdlet):
open_id = None
i += 2
continue
if low in store_flags and i + 1 < len(args_list):
storage_backend = args_list[i + 1]
i += 2
elif low in limit_flags and i + 1 < len(args_list):
if low in limit_flags and i + 1 < len(args_list):
limit_set = True
try:
limit = int(args_list[i + 1])
@@ -1820,6 +1811,9 @@ class search_file(Cmdlet):
query = query.strip()
if not plugin_name and instance_name and not storage_backend:
storage_backend = instance_name
if plugin_name:
if storage_backend and not instance_name:
instance_name = storage_backend