dfdf
This commit is contained in:
@@ -31,7 +31,7 @@ CMDLET = Cmdlet(
|
||||
arg=[
|
||||
CmdletArg("path", type="string", description="Specify the local file path (if not piping a result)."),
|
||||
SharedArgs.STORE,
|
||||
SharedArgs.HASH,
|
||||
SharedArgs.QUERY,
|
||||
CmdletArg("-king", type="string", description="Explicitly set the king hash/file for relationships (e.g., -king @4 or -king hash)"),
|
||||
CmdletArg("-alt", type="string", description="Explicitly select alt item(s) by @ selection or hash list (e.g., -alt @3-5 or -alt <hash>,<hash>)"),
|
||||
CmdletArg("-type", type="string", description="Relationship type for piped items (default: 'alt', options: 'king', 'alt', 'related')"),
|
||||
@@ -372,7 +372,7 @@ def _refresh_relationship_view_if_current(target_hash: Optional[str], target_pat
|
||||
|
||||
refresh_args: list[str] = []
|
||||
if target_hash:
|
||||
refresh_args.extend(["-hash", target_hash])
|
||||
refresh_args.extend(["-query", f"hash:{target_hash}"])
|
||||
get_relationship(subject, refresh_args, config)
|
||||
except Exception:
|
||||
pass
|
||||
@@ -396,7 +396,10 @@ def _run(result: Any, _args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
parsed = parse_cmdlet_args(_args, CMDLET)
|
||||
arg_path: Optional[Path] = None
|
||||
override_store = parsed.get("store")
|
||||
override_hash = parsed.get("hash")
|
||||
override_hashes = sh.parse_hash_query(parsed.get("query"))
|
||||
if parsed.get("query") and not override_hashes:
|
||||
log("Invalid -query value (expected hash:<sha256>)", file=sys.stderr)
|
||||
return 1
|
||||
king_arg = parsed.get("king")
|
||||
alt_arg = parsed.get("alt")
|
||||
rel_type = parsed.get("type", "alt")
|
||||
@@ -436,20 +439,12 @@ def _run(result: Any, _args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
resolved_alt_items = [{"hash": h, "store": str(override_store)} for h in hashes]
|
||||
items_to_process = normalize_result_input(resolved_alt_items)
|
||||
|
||||
# Allow explicit -hash operation (store/hash-first)
|
||||
if (not items_to_process) and override_hash:
|
||||
# Support comma-separated hashes
|
||||
raw = str(override_hash)
|
||||
parts = [p.strip() for p in raw.replace(";", ",").split(",")]
|
||||
hashes = [h for h in (_normalise_hash_hex(p) for p in parts) if h]
|
||||
if not hashes:
|
||||
log("Invalid -hash value (expected 64-hex sha256)", file=sys.stderr)
|
||||
return 1
|
||||
# Use the selected/override store; required in this mode
|
||||
# Allow explicit store/hash-first operation via -query "hash:<sha256>" (supports multiple hash: tokens)
|
||||
if (not items_to_process) and override_hashes:
|
||||
if not override_store:
|
||||
log("-store is required when using -hash without piped items", file=sys.stderr)
|
||||
log("-store is required when using -query without piped items", file=sys.stderr)
|
||||
return 1
|
||||
items_to_process = [{"hash": h, "store": str(override_store)} for h in hashes]
|
||||
items_to_process = [{"hash": h, "store": str(override_store)} for h in override_hashes]
|
||||
|
||||
if not items_to_process and not arg_path:
|
||||
log("No items provided to add-relationship (no piped result and no -path)", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user