update local and mpv plugins, add file cmdlet, update docs
This commit is contained in:
+20
-6
@@ -21,7 +21,6 @@ class File(Cmdlet):
|
||||
"get": {"-get", "--get"},
|
||||
"merge": {"-merge", "--merge"},
|
||||
"download": {"-download", "--download", "-dl", "--dl"},
|
||||
"search": {"-search", "--search"},
|
||||
"convert": {"-convert", "--convert"},
|
||||
"trim": {"-trim", "--trim"},
|
||||
"archive": {"-archive", "--archive"},
|
||||
@@ -45,9 +44,10 @@ class File(Cmdlet):
|
||||
super().__init__(
|
||||
name="file",
|
||||
summary="Manage file operations with one command",
|
||||
usage='file (-add|-delete|-get|-merge|-download|-search|-convert|-trim|-archive|-screenshot) [args]',
|
||||
usage='file -query <query> [args] | file (-add|-delete|-get|-merge|-download|-convert|-trim|-archive|-screenshot) [args]',
|
||||
arg=[
|
||||
SharedArgs.QUERY,
|
||||
SharedArgs.PLUGIN,
|
||||
SharedArgs.INSTANCE,
|
||||
SharedArgs.PATH,
|
||||
CmdletArg("-add", type="flag", required=False, description="Run add-file"),
|
||||
@@ -55,21 +55,32 @@ class File(Cmdlet):
|
||||
CmdletArg("-get", type="flag", required=False, description="Run get-file"),
|
||||
CmdletArg("-merge", type="flag", required=False, description="Run merge-file"),
|
||||
CmdletArg("-download", type="flag", required=False, description="Run download-file", alias="dl"),
|
||||
CmdletArg("-search", type="flag", required=False, description="Run search-file"),
|
||||
CmdletArg("-convert", type="flag", required=False, description="Run convert-file"),
|
||||
CmdletArg("-trim", type="flag", required=False, description="Run trim-file"),
|
||||
CmdletArg("-archive", type="flag", required=False, description="Run archive-file"),
|
||||
CmdletArg("-screenshot", type="flag", required=False, description="Run screen-shot", alias="shot"),
|
||||
],
|
||||
detail=[
|
||||
"- Exactly one action flag is required.",
|
||||
"- Use -query to run search-file through the unified file command.",
|
||||
"- Otherwise, exactly one non-search action flag is required.",
|
||||
"- Remaining args are passed through to the selected file cmdlet.",
|
||||
"- Examples: file -add ..., file -delete ..., file -merge ...",
|
||||
"- Examples: file -query ..., file -add ..., file -delete ...",
|
||||
],
|
||||
exec=self.run,
|
||||
)
|
||||
self.register()
|
||||
|
||||
@staticmethod
|
||||
def _has_query_arg(args: Sequence[str]) -> bool:
|
||||
query_flags = {"-query", "--query"}
|
||||
for token in args or []:
|
||||
text = str(token or "").strip().lower()
|
||||
if text in query_flags:
|
||||
return True
|
||||
if any(text.startswith(f"{flag}=") for flag in query_flags):
|
||||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def _extract_action(cls, args: Sequence[str]) -> tuple[str | None, List[str], List[str]]:
|
||||
matched_actions: List[str] = []
|
||||
@@ -93,6 +104,9 @@ class File(Cmdlet):
|
||||
if action not in unique_actions:
|
||||
unique_actions.append(action)
|
||||
|
||||
if not unique_actions and cls._has_query_arg(passthrough):
|
||||
return "search", passthrough, unique_actions
|
||||
|
||||
if len(unique_actions) != 1:
|
||||
return None, passthrough, unique_actions
|
||||
return unique_actions[0], passthrough, unique_actions
|
||||
@@ -125,7 +139,7 @@ class File(Cmdlet):
|
||||
if action is None:
|
||||
if not seen:
|
||||
log(
|
||||
"file: missing action flag; choose exactly one of -add, -delete, -get, -merge, -download, -search, -convert, -trim, -archive, -screenshot",
|
||||
"file: missing action; use -query for search or choose exactly one of -add, -delete, -get, -merge, -download, -convert, -trim, -archive, -screenshot",
|
||||
file=sys.stderr,
|
||||
)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user