jkj
This commit is contained in:
@@ -9,13 +9,13 @@ import subprocess
|
||||
import webbrowser
|
||||
|
||||
import pipeline as ctx
|
||||
from ._shared import Cmdlet, CmdletArg, SharedArgs, parse_cmdlet_args, get_field, normalize_hash
|
||||
from . import _shared as sh
|
||||
from SYS.logger import log, debug
|
||||
from Store import Store
|
||||
from config import resolve_output_dir
|
||||
|
||||
|
||||
class Get_File(Cmdlet):
|
||||
class Get_File(sh.Cmdlet):
|
||||
"""Export files to local path via hash+store."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
@@ -25,10 +25,10 @@ class Get_File(Cmdlet):
|
||||
summary="Export file to local path",
|
||||
usage="@1 | get-file -path C:\\Downloads",
|
||||
arg=[
|
||||
SharedArgs.HASH,
|
||||
SharedArgs.STORE,
|
||||
SharedArgs.PATH,
|
||||
CmdletArg("name", description="Output filename (default: from metadata title)"),
|
||||
sh.SharedArgs.HASH,
|
||||
sh.SharedArgs.STORE,
|
||||
sh.SharedArgs.PATH,
|
||||
sh.CmdletArg("name", description="Output filename (default: from metadata title)"),
|
||||
],
|
||||
detail=[
|
||||
"- Exports file from storage backend to local path",
|
||||
@@ -42,12 +42,12 @@ class Get_File(Cmdlet):
|
||||
def run(self, result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
"""Export file via hash+store backend."""
|
||||
debug(f"[get-file] run() called with result type: {type(result)}")
|
||||
parsed = parse_cmdlet_args(args, self)
|
||||
parsed = sh.parse_cmdlet_args(args, self)
|
||||
debug(f"[get-file] parsed args: {parsed}")
|
||||
|
||||
# Extract hash and store from result or args
|
||||
file_hash = parsed.get("hash") or get_field(result, "hash")
|
||||
store_name = parsed.get("store") or get_field(result, "store")
|
||||
file_hash = parsed.get("hash") or sh.get_field(result, "hash")
|
||||
store_name = parsed.get("store") or sh.get_field(result, "store")
|
||||
output_path = parsed.get("path")
|
||||
output_name = parsed.get("name")
|
||||
|
||||
@@ -62,7 +62,7 @@ class Get_File(Cmdlet):
|
||||
return 1
|
||||
|
||||
# Normalize hash
|
||||
file_hash = normalize_hash(file_hash)
|
||||
file_hash = sh.normalize_hash(file_hash)
|
||||
if not file_hash:
|
||||
log("Error: Invalid hash format")
|
||||
return 1
|
||||
@@ -84,9 +84,9 @@ class Get_File(Cmdlet):
|
||||
|
||||
def resolve_display_title() -> str:
|
||||
candidates = [
|
||||
get_field(result, "title"),
|
||||
get_field(result, "name"),
|
||||
get_field(result, "filename"),
|
||||
sh.get_field(result, "title"),
|
||||
sh.get_field(result, "name"),
|
||||
sh.get_field(result, "filename"),
|
||||
(metadata.get("title") if isinstance(metadata, dict) else None),
|
||||
(metadata.get("name") if isinstance(metadata, dict) else None),
|
||||
(metadata.get("filename") if isinstance(metadata, dict) else None),
|
||||
|
||||
Reference in New Issue
Block a user