def cli(ctx, message, key, config, verbose):
"""Use simplepush and tasker to push text to remote phone's clipboard."""
if ctx.invoked_subcommand is None:
if not os.path.exists(config):
click.echo("Config file: {}".format(config))
click.echo("Config file does not exist. Please choose a different file, or initialize with push2clip init <key>")
quit()
with open(config, 'r') as f:
conf = json.load(f)
f.close()
if not key:
if not conf['key']:
print("Error: Simplepush key is missing. Unable to send push.")
quit()
key = conf['key']
if not message:
message = click.get_text_stream('stdin').read()
event = conf.get("event", '')
title = conf.get("title", '')
sp = simplepush(key, event=event, title=title, message=message)
if not sp:
click.echo("An error was encountered while pushing message.")
else:
if verbose:
click.echo("Push sent successfully.")
click.echo("Key: {}".format(key))
click.echo("Event: {}".format(event))
click.echo("Title: {}".format(title))
click.echo("Message: {}".format(message))
评论列表
文章目录