38 lines
728 B
Python
38 lines
728 B
Python
#!/usr/bin/env python3
|
|
"""Something misc."""
|
|
import sys
|
|
import click
|
|
|
|
from Crypto.PublicKey import RSA
|
|
from demo import config
|
|
from demo.boxes import send_note
|
|
|
|
@click.group()
|
|
def misc():
|
|
pass
|
|
|
|
|
|
@click.command()
|
|
def gen_key(self):
|
|
"""Generate key."""
|
|
if config.KEY_PATH.exists():
|
|
print("Key is existing!")
|
|
sys.exit(2)
|
|
else:
|
|
k = RSA.generate(2048)
|
|
privkey_pem = k.exportKey("PEM").decode("utf-8")
|
|
config.KEY_PATH.write_text(privkey_pem)
|
|
print("Done!")
|
|
|
|
|
|
@click.command()
|
|
@click.option("--content", prompt="Note content")
|
|
def creat_note(content):
|
|
send_note(content)
|
|
|
|
|
|
misc.add_command(gen_key)
|
|
misc.add_command(creat_note)
|
|
|
|
if __name__ == "__main__":
|
|
misc()
|