Compare commits

..

No commits in common. "12dbe87134a790e780301d3de9a7d5fb34b4ae1a" and "349a9cbd0e41a17f9db70cf3dc5342a766824b68" have entirely different histories.

5 changed files with 12 additions and 49 deletions

View file

@ -18,12 +18,15 @@ from sshare.plugin import Plugin
class Logger:
def __init__(self, *args, **kwargs):
self._loggers = []
if kwargs.get("command_line"):
self._loggers = [ kwargs["command_line"] ]
else:
self._loggers = []
self.add(*args)
def add(self, *args, **kwargs):
for logger in args:
self._loggers.append(logger)
self._loggers.append()
def info(self, message):
for logger in self._loggers:

View file

@ -67,10 +67,9 @@ def main():
config["config"],
config["flags"],
)
logger = Logger(command_line)
plugin_types = [ "logger", "source", "name", "upload", "location", "feedback" ]
logger = Logger(command_line=command_line)
plugins = PluginManager(
plugin_types,
[ "logger", "source", "name", "upload", "location", "feedback" ],
logger,
config["config"],
config["flags"],
@ -79,7 +78,6 @@ def main():
plugins.add_from(
Plugin.internal(INTERNAL_PLUGIN_LOCATION),
"file",
"stdin",
"current_time",
"append_type",
"ssh",
@ -101,16 +99,6 @@ def main():
logger.add(*plugins.logger.active)
plugins.activate()
for plugin_type in [ "source", "name", "upload" ]:
plugins_of_type = getattr(plugins, plugin_type)
if len(plugins_of_type.active) == 0:
logger.error(f"Error: No '{plugin_type}' plugins activated. Available plugins:")
for plugin in plugins_of_type.inactive:
logger.error(f" => {plugin.name}")
sys.exit(1)
if len(plugins.location.active) == 0 and len(plugins.feedback.active) > 0:
logger.warn("Warning: 'feedback' plugins activated with no active 'location' plugins")
sources = []
for plugin in plugins.source.active:
sources.append(plugin.get_source())

View file

@ -75,8 +75,8 @@ class Argument:
def add(self, arg_parser):
flags = []
if self._short != None: flags.append(f"-{self._short}")
if self._long != None: flags.append(f"--{self._long}")
if self._short: flags.append(f"-{self._short}")
if self._long: flags.append(f"--{self._long}")
kwargs = self._kwargs | {
"dest": self.dest()
}

View file

@ -22,6 +22,9 @@ plugin_type = "name"
config = {
"base": 62,
}
args = {
"base": Argument(help="Set the numeric base to use for the current time"),
}
def init():
if not isinstance(config.base, int):

View file

@ -1,31 +0,0 @@
# 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 <https://www.gnu.org/licenses/>.
import sys
from sshare.plugins.config import Flag
from sshare.plugins.source import Raw
plugin_type = "source"
activate = { "stdin" }
config = {
"suffix": "txt"
}
args = {
"stdin": Flag(help="Upload from stdin")
}
def get_source():
return Raw(config.suffix, sys.stdin.buffer.read())