diff --git a/src/sshare/logger.py b/src/sshare/logger.py index 60d804c..7901d4c 100644 --- a/src/sshare/logger.py +++ b/src/sshare/logger.py @@ -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: diff --git a/src/sshare/main.py b/src/sshare/main.py index 023480a..cb0812d 100644 --- a/src/sshare/main.py +++ b/src/sshare/main.py @@ -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()) diff --git a/src/sshare/plugins/config.py b/src/sshare/plugins/config.py index 6df34ed..31c18d8 100644 --- a/src/sshare/plugins/config.py +++ b/src/sshare/plugins/config.py @@ -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() } diff --git a/src/sshare/plugins/default/current_time.py b/src/sshare/plugins/default/current_time.py index 062ff86..03c1692 100644 --- a/src/sshare/plugins/default/current_time.py +++ b/src/sshare/plugins/default/current_time.py @@ -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): diff --git a/src/sshare/plugins/default/stdin.py b/src/sshare/plugins/default/stdin.py deleted file mode 100644 index df359e4..0000000 --- a/src/sshare/plugins/default/stdin.py +++ /dev/null @@ -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 . - -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())