Add 'stdin' plugin. Allow flags to be empty (e.g. '-' and '--')
This commit is contained in:
parent
fb79537707
commit
12dbe87134
3 changed files with 34 additions and 2 deletions
|
@ -79,6 +79,7 @@ def main():
|
|||
plugins.add_from(
|
||||
Plugin.internal(INTERNAL_PLUGIN_LOCATION),
|
||||
"file",
|
||||
"stdin",
|
||||
"current_time",
|
||||
"append_type",
|
||||
"ssh",
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
31
src/sshare/plugins/default/stdin.py
Normal file
31
src/sshare/plugins/default/stdin.py
Normal 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())
|
Loading…
Reference in a new issue