Replace 'result' plugin type with 'feedback'

This commit is contained in:
Gnarwhal 2024-09-08 21:13:12 +00:00
parent 1466438938
commit 92bb65a049
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
2 changed files with 8 additions and 30 deletions

View file

@ -18,17 +18,11 @@ 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", "feedback" }
activate = {
"source": { "from_clipboard" },
"result": { "to_clipboard" },
}
config = {
"protocol": "https",
"host": NoDefault,
"port": None,
"path": "",
"feedback": { "to_clipboard" },
}
args = {
"from_clipboard": Flag(
@ -47,9 +41,5 @@ def get_source():
logger.info("Uploading contents of clipboard")
return Raw("txt", pyclip.paste())
def result(name):
if config.port:
config.port = f":{config.port}"
else:
config.port = ""
pyclip.copy(f"{config.protocol}://{config.host}{config.port}{config.path}/{name}")
def give_feedback(location):
pyclip.copy(location)

View file

@ -12,20 +12,14 @@
# You should have received a copy of the GNU General Public License along with
# SSHare. If not, see <https://www.gnu.org/licenses/>.
from desktop_notifier import DesktopNotifierSync, Urgency, Button
from desktop_notifier import DesktopNotifierSync
from sshare.plugins.config import Flag
from sshare.plugins.config import NoDefault
plugin_type = "result"
plugin_type = "feedback"
activate = { "notify" }
config = {
"protocol": "https",
"host": NoDefault,
"port": None,
"path": "",
}
args = {
"notify": Flag(
short="n",
@ -35,14 +29,8 @@ args = {
_notifier = DesktopNotifierSync()
def result(name):
if config.port:
config.port = f":{config.port}"
else:
config.port = ""
url = f"{config.protocol}://{config.host}{config.port}{config.path}/{name}"
def give_feedback(location):
_notifier.send(
title="SSHare - Upload Complete",
message=f"Uploaded to {url}",
message=f"Uploaded to {location}",
)