|
@ -15,6 +15,9 @@ from corvus.service import user_service |
|
|
logging.basicConfig() |
|
|
logging.basicConfig() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENCODING = 'utf-8' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.group() |
|
|
@click.group() |
|
|
def main(): |
|
|
def main(): |
|
|
pass |
|
|
pass |
|
@ -25,6 +28,11 @@ def user_command_group(): |
|
|
pass |
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.group(name='base64') |
|
|
|
|
|
def base64_command_group(): |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command(name='delete') |
|
|
@click.command(name='delete') |
|
|
@click.argument('name') |
|
|
@click.argument('name') |
|
|
def delete_user(name: str): |
|
|
def delete_user(name: str): |
|
@ -112,14 +120,24 @@ def list_users(): |
|
|
[click.echo(user.name) for user in all_users] |
|
|
[click.echo(user.name) for user in all_users] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command(name='base64') |
|
|
|
|
|
|
|
|
@click.command(name='encode') |
|
|
@click.argument('text') |
|
|
@click.argument('text') |
|
|
def convert_to_base64(text: str): |
|
|
def convert_to_base64(text: str): |
|
|
print(base64.b64encode(text.encode('utf8')).decode('utf8')) |
|
|
|
|
|
|
|
|
encoded_text = base64.standard_b64encode(text.encode(ENCODING)).decode(ENCODING) |
|
|
|
|
|
logging.info('Encoded base64: \'%s\'', encoded_text) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command(name='decode') |
|
|
|
|
|
@click.argument('text') |
|
|
|
|
|
def convert_from_base64(text: str): |
|
|
|
|
|
decoded_text = base64.standard_b64decode(text.encode(ENCODING)).decode(ENCODING) |
|
|
|
|
|
logging.info('Decoded base64: \'%s\'', decoded_text) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.add_command(base64_command_group) |
|
|
|
|
|
base64_command_group.add_command(convert_to_base64) |
|
|
|
|
|
base64_command_group.add_command(convert_from_base64) |
|
|
main.add_command(user_command_group) |
|
|
main.add_command(user_command_group) |
|
|
main.add_command(convert_to_base64) |
|
|
|
|
|
user_command_group.add_command(register_user) |
|
|
user_command_group.add_command(register_user) |
|
|
user_command_group.add_command(register_admin_user) |
|
|
user_command_group.add_command(register_admin_user) |
|
|
user_command_group.add_command(delete_user) |
|
|
user_command_group.add_command(delete_user) |
|
|