From eedc1d56791dc08f844034e8dc588efc9de03503 Mon Sep 17 00:00:00 2001 From: raphael Date: Mon, 17 Jan 2022 15:09:47 +0100 Subject: [PATCH] enables piping to bump cli - sys.stdin is queried for data if no message is passed to the cli directly - sys stdin content is then passed as the title of a message to the senders --- bump/cli.py | 11 ++++++++++- setup.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bump/cli.py b/bump/cli.py index be7d8e4..7636fed 100644 --- a/bump/cli.py +++ b/bump/cli.py @@ -1,6 +1,8 @@ from typing import Optional import bump import typer +import sys +import select def default( @@ -9,16 +11,23 @@ def default( reset:Optional[bool] = typer.Option(False, help="remove all senders"), alert:Optional[bool] = typer.Option(False, help="check continuously for new messages"), secret:Optional[str] = typer.Option(None, help="change the sender and e2e keys")): + bp = bump.Bump() + + pipe = None + if select.select([sys.stdin,],[],[],0.0)[0]: + pipe = sys.stdin.readline() if message_arg is not None: push(message_arg) + elif pipe is not None: + push(pipe) elif message is not None: push(message) elif secret is not None: secrets(secret) elif reset: delete_senders() - elif alert is not None: + elif alert: alert_process() else: info() diff --git a/setup.py b/setup.py index 720ccf0..94f0ba9 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name='bump_python', packages=['bump'], description='Notify your Phone from Python', - version='0.1.4', + version='0.1.5', url='https://git.maenle.tech/raphael/bump_python', author='Raphael Maenle', author_email='raphael@maenle.net',