Utilize 'Flag' convenience function and migrate from [] to {} as appropriate

This commit is contained in:
Gnarwhal 2024-09-08 20:10:03 +00:00
parent f8b077f376
commit 1466438938
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
3 changed files with 9 additions and 18 deletions

View file

@ -14,16 +14,15 @@
import pyclip
from sshare.plugins.config import Argument
from sshare.plugins.config import Flag
from sshare.plugins.config import NoDefault
from sshare.plugins.source import Raw
plugin_type = [ "source", "result" ]
plugin_type = { "source", "result" }
activate = {
"source": [ "from_clipboard" ],
"result": [ "to_clipboard" ],
"source": { "from_clipboard" },
"result": { "to_clipboard" },
}
config = {
"protocol": "https",
@ -32,18 +31,14 @@ config = {
"path": "",
}
args = {
"from_clipboard": Argument(
"from_clipboard": Flag(
short="p",
long="paste",
action="store_const",
const=Flag,
help="Upload the contents of the clipboard"
),
"to_clipboard": Argument(
"to_clipboard": Flag(
short="c",
long="copy",
action="store_const",
const=Flag,
help="Copy the resultant URL to the clipboard"
),
}

View file

@ -22,7 +22,7 @@ from sshare.plugins.source import File
plugin_type = "source"
activate = [ "directory" ]
activate = { "directory" }
config = {
"directory": NoDefault
}

View file

@ -14,13 +14,12 @@
from desktop_notifier import DesktopNotifierSync, Urgency, Button
from sshare.plugins.config import Argument
from sshare.plugins.config import Flag
from sshare.plugins.config import NoDefault
plugin_type = [ "result" ]
plugin_type = "result"
activate = [ "activate" ]
activate = { "notify" }
config = {
"protocol": "https",
"host": NoDefault,
@ -28,11 +27,8 @@ config = {
"path": "",
}
args = {
"activate": Argument(
"notify": Flag(
short="n",
long="notify",
action="store_const",
const=Flag,
help="Send a desktop notification"
)
}