add command to create password

This commit is contained in:
Antonio J. Delgado 2024-11-10 17:13:54 +02:00
parent 09155d0f46
commit f8af1c4896

View file

@ -50,6 +50,10 @@ class NcPasswordClient:
'''List all passwords'''
print(json.dumps(self.nc.list_passwords(), indent=2))
def create_password(self, obj):
'''Create a password with an object'''
print(json.dumps(self.nc.create_password(obj), indent=2))
def _init_log(self):
''' Initialize log object '''
self._log = logging.getLogger("nc_password_client")
@ -145,5 +149,13 @@ def list(ctx):
'''Show all password'''
ctx.obj['NcPasswordClient'].list_passwords()
@cli.command()
@click.option('--obj', '-o', required=True, help='JSON object for a password')
@click_config_file.configuration_option()
@click.pass_context
def create_password(ctx, obj):
'''Show all password'''
ctx.obj['NcPasswordClient'].create_password(json.loads(obj))
if __name__ == "__main__":
cli(obj={})