2022-01-17 11:44:43 +01:00
|
|
|
from typing import Optional
|
2022-01-16 22:24:23 +01:00
|
|
|
import bump
|
|
|
|
import typer
|
2022-01-17 15:09:47 +01:00
|
|
|
import sys
|
|
|
|
import select
|
2022-01-16 22:24:23 +01:00
|
|
|
|
|
|
|
|
2022-01-17 11:44:43 +01:00
|
|
|
def default(
|
|
|
|
message_arg:Optional[str] = typer.Argument(None, help="The message to be bumped"),
|
|
|
|
message:Optional[str] = typer.Option(None, help="The message to be bumped"),
|
2022-01-17 15:00:47 +01:00
|
|
|
reset:Optional[bool] = typer.Option(False, help="remove all senders"),
|
|
|
|
alert:Optional[bool] = typer.Option(False, help="check continuously for new messages"),
|
2022-01-17 11:44:43 +01:00
|
|
|
secret:Optional[str] = typer.Option(None, help="change the sender and e2e keys")):
|
2022-01-17 15:09:47 +01:00
|
|
|
|
2022-01-16 22:24:23 +01:00
|
|
|
bp = bump.Bump()
|
2022-01-17 15:09:47 +01:00
|
|
|
|
|
|
|
pipe = None
|
|
|
|
if select.select([sys.stdin,],[],[],0.0)[0]:
|
|
|
|
pipe = sys.stdin.readline()
|
2022-01-17 11:44:43 +01:00
|
|
|
if message_arg is not None:
|
|
|
|
push(message_arg)
|
2022-01-17 15:09:47 +01:00
|
|
|
elif pipe is not None:
|
|
|
|
push(pipe)
|
2022-01-17 11:44:43 +01:00
|
|
|
elif message is not None:
|
|
|
|
push(message)
|
|
|
|
elif secret is not None:
|
|
|
|
secrets(secret)
|
|
|
|
elif reset:
|
|
|
|
delete_senders()
|
2022-01-17 15:09:47 +01:00
|
|
|
elif alert:
|
2022-01-17 15:00:47 +01:00
|
|
|
alert_process()
|
2022-01-16 22:24:23 +01:00
|
|
|
else:
|
2022-01-17 11:44:43 +01:00
|
|
|
info()
|
2022-01-16 22:24:23 +01:00
|
|
|
|
2022-01-17 11:44:43 +01:00
|
|
|
def delete_senders():
|
2022-01-16 22:24:23 +01:00
|
|
|
bp = bump.Bump()
|
2022-01-17 11:44:43 +01:00
|
|
|
bp.delete_senders()
|
|
|
|
|
2022-01-17 15:00:47 +01:00
|
|
|
def alert_process():
|
2022-01-17 11:44:43 +01:00
|
|
|
bp = bump.Bump()
|
|
|
|
bp.alert()
|
|
|
|
|
|
|
|
def secrets(secret:str):
|
|
|
|
if secret is not None:
|
|
|
|
bp = bump.Bump(secret)
|
|
|
|
info()
|
|
|
|
|
|
|
|
def push(message:str):
|
|
|
|
bp = bump.Bump()
|
|
|
|
bp.push(message)
|
|
|
|
|
|
|
|
def info():
|
|
|
|
bp = bump.Bump()
|
|
|
|
bp.show_secret()
|
2022-01-16 22:24:23 +01:00
|
|
|
|
|
|
|
def main():
|
|
|
|
typer.run(default)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|