diff --git a/src/sshare/main.py b/src/sshare/main.py index dd071ac..023480a 100644 --- a/src/sshare/main.py +++ b/src/sshare/main.py @@ -79,6 +79,7 @@ def main(): plugins.add_from( Plugin.internal(INTERNAL_PLUGIN_LOCATION), "file", + "stdin", "current_time", "append_type", "ssh", diff --git a/src/sshare/plugins/config.py b/src/sshare/plugins/config.py index 31c18d8..6df34ed 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: flags.append(f"-{self._short}") - if self._long: flags.append(f"--{self._long}") + if self._short != None: flags.append(f"-{self._short}") + if self._long != None: flags.append(f"--{self._long}") kwargs = self._kwargs | { "dest": self.dest() } diff --git a/src/sshare/plugins/default/stdin.py b/src/sshare/plugins/default/stdin.py new file mode 100644 index 0000000..df359e4 --- /dev/null +++ b/src/sshare/plugins/default/stdin.py @@ -0,0 +1,31 @@ +# 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())