From 0cbb81abdf123a7ce1ff25675f427a550e2dd59f Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Tue, 10 Sep 2024 15:11:02 +0000 Subject: [PATCH] Add ability to specify type for clipboard contents --- clipboard.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clipboard.py b/clipboard.py index aa11fcb..5031e67 100644 --- a/clipboard.py +++ b/clipboard.py @@ -14,6 +14,7 @@ import pyclip +from sshare.plugin.config import Argument from sshare.plugin.config import Flag from sshare.plugin.config import NoDefault from sshare.plugin.source import Raw @@ -21,13 +22,16 @@ from sshare.plugin.source import Raw plugin_type = { "source", "feedback" } activate = { - "source": { "from_clipboard" }, + "source": { "type" }, "feedback": { "to_clipboard" }, } args = { - "from_clipboard": Flag( + "type": Argument( name="paste", - help="Upload the contents of the clipboard" + nargs="?", + const=Flag, + default="txt", + help="Upload the contents of the clipboard as text" ), "to_clipboard": Flag( name="copy", @@ -37,7 +41,7 @@ args = { def get_source(): logger.info("Uploading contents of clipboard") - return Raw("txt", pyclip.paste()) + return Raw(config.type, pyclip.paste()) def give_feedback(location): pyclip.copy(location)