Add 'stdin' plugin. Allow flags to be empty (e.g. '-' and '--')

This commit is contained in:
Gnarwhal 2024-09-09 18:34:23 +00:00
parent fb79537707
commit 12dbe87134
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
3 changed files with 34 additions and 2 deletions

View file

@ -79,6 +79,7 @@ def main():
plugins.add_from(
Plugin.internal(INTERNAL_PLUGIN_LOCATION),
"file",
"stdin",
"current_time",
"append_type",
"ssh",

View file

@ -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()
}

View file

@ -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 <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())