diff --git a/examples b/examples
index 1466438..92bb65a 160000
--- a/examples
+++ b/examples
@@ -1 +1 @@
-Subproject commit 1466438938c98442aa6de55065b7e6a06a7e8d50
+Subproject commit 92bb65a049942b127ee6108bff5812c110acfe12
diff --git a/src/sshare/main.py b/src/sshare/main.py
index 3a71c08..1a13a1b 100644
--- a/src/sshare/main.py
+++ b/src/sshare/main.py
@@ -26,7 +26,6 @@ from sshare.plugin import Plugin
from sshare.plugin import PluginManager
from sshare.version import version
-
def main():
arg_parser = argparse.ArgumentParser(
prog="sshare",
@@ -63,7 +62,7 @@ def main():
command_line = Plugin.internal(INTERNAL_PLUGIN_LOCATION, "command_line", config.get("plugins", dict()))
logger = Logger(command_line=command_line)
plugins = PluginManager(
- [ "logger", "source", "name", "upload", "result" ],
+ [ "logger", "source", "name", "upload", "location", "feedback" ],
logger,
config.get("plugins", dict()),
arg_parser,
@@ -74,7 +73,8 @@ def main():
"current_time",
"append_type",
"ssh",
- "log_result",
+ "uri",
+ "print_location",
)
sys.dont_write_bytecode = True
plugins.add_from(
@@ -94,8 +94,6 @@ def main():
sources = []
for plugin in plugins.source.active:
sources.append(plugin.get_source())
- if len(sources) == 0:
- logger.error("Error: No sources provided. Must activate at least one source plugin.")
for index, source in enumerate(sources):
name = ""
@@ -107,8 +105,12 @@ def main():
for plugin in plugins.upload.active:
plugin.upload(name, source)
- for name, _ in sources:
- for plugin in plugins.result.active:
- plugin.result(name)
+ for index, (name, _) in enumerate(sources):
+ for plugin in plugins.location.active:
+ sources[index] = plugin.get_location(name)
+
+ for location in sources:
+ for plugin in plugins.feedback.active:
+ sources[index] = plugin.give_feedback(location)
sys.exit(0)
diff --git a/src/sshare/plugins/default/append_type.py b/src/sshare/plugins/default/append_type.py
index 9263be6..aedcca2 100644
--- a/src/sshare/plugins/default/append_type.py
+++ b/src/sshare/plugins/default/append_type.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License along with
# SSHare. If not, see .
-from ..source import File
-from ..source import Raw
+from sshare.plugins.source import File
+from sshare.plugins.source import Raw
plugin_type = "name"
diff --git a/src/sshare/plugins/default/current_time.py b/src/sshare/plugins/default/current_time.py
index a82ba27..b11dec5 100644
--- a/src/sshare/plugins/default/current_time.py
+++ b/src/sshare/plugins/default/current_time.py
@@ -14,8 +14,8 @@
import time
-from ..config import Argument
-from ..source import File
+from sshare.plugins.config import Argument
+from sshare.plugins.source import File
plugin_type = "name"
diff --git a/src/sshare/plugins/default/file.py b/src/sshare/plugins/default/file.py
index b51a346..ccadbba 100644
--- a/src/sshare/plugins/default/file.py
+++ b/src/sshare/plugins/default/file.py
@@ -12,9 +12,9 @@
# You should have received a copy of the GNU General Public License along with
# SSHare. If not, see .
-from ..config import Argument
-from ..config import NoDefault
-from ..source import File
+from sshare.plugins.config import Argument
+from sshare.plugins.config import NoDefault
+from sshare.plugins.source import File
plugin_type = "source"
diff --git a/src/sshare/plugins/default/print_location.py b/src/sshare/plugins/default/print_location.py
new file mode 100644
index 0000000..ed2991e
--- /dev/null
+++ b/src/sshare/plugins/default/print_location.py
@@ -0,0 +1,18 @@
+# This file is part of SSHare.
+#
+# SSHare is free software: you can redistribute it and/or modify it under the terms of
+# the GNU General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later version.
+#
+# SSHare is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# SSHare. If not, see .
+
+plugin_type = "feedback"
+
+def give_feedback(location):
+ logger.info(f"Uploaded to '{location}'")
diff --git a/src/sshare/plugins/default/ssh.py b/src/sshare/plugins/default/ssh.py
index 6aca493..e73bd20 100644
--- a/src/sshare/plugins/default/ssh.py
+++ b/src/sshare/plugins/default/ssh.py
@@ -15,9 +15,9 @@
import getpass
import subprocess
-from ..config import NoDefault
-from ..source import File
-from ..source import Raw
+from sshare.plugins.config import NoDefault
+from sshare.plugins.source import File
+from sshare.plugins.source import Raw
plugin_type = "upload"
diff --git a/src/sshare/plugins/default/log_result.py b/src/sshare/plugins/default/uri.py
similarity index 82%
rename from src/sshare/plugins/default/log_result.py
rename to src/sshare/plugins/default/uri.py
index 9884385..b6f0997 100644
--- a/src/sshare/plugins/default/log_result.py
+++ b/src/sshare/plugins/default/uri.py
@@ -12,9 +12,9 @@
# You should have received a copy of the GNU General Public License along with
# SSHare. If not, see .
-from ..config import NoDefault
+from sshare.plugins.config import NoDefault
-plugin_type = "result"
+plugin_type = "location"
config = {
"protocol": "https",
@@ -23,9 +23,9 @@ config = {
"path": "",
}
-def result(name):
+def get_location(name):
if config.port:
config.port = f":{config.port}"
else:
config.port = ""
- logger.info(f"Uploaded to '{config.protocol}://{config.host}{config.port}{config.path}/{name}'")
+ return f"{config.protocol}://{config.host}{config.port}{config.path}/{name}"