Verified Commit 79494e28 authored by Peter Stanko's avatar Peter Stanko
Browse files

Fixes in the commands

parent 29baff0b
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -86,24 +86,24 @@ def cli_role_users_list(obj: AppConfig, remote, course, codename: str):
@click.option('-r', '--remote', required=False, help='Sets remote')
@click.option('-c', '--course', required=False, help='Select course')
@click.argument('codename')
@click.argument('user')
@click.argument('client')
@click.pass_obj
def cli_role_users_add(obj: AppConfig, remote, course, codename: str, user: str):
def cli_role_users_add(obj: AppConfig, remote, course, codename: str, client: str):
    remote: Remote = helpers.get_remote(obj, remote)
    course = helpers.get_course(remote, course)
    helpers.generic_add_client(course.roles, codename, user)
    helpers.generic_add_client(course.roles, codename, client)


@cli_role_users.command('rm', help='Removes user from the role')
@cli_role_users.command('rm', help='Remove client from the role')
@click.option('-r', '--remote', required=False, help='Sets remote')
@click.option('-c', '--course', required=False, help='Select course')
@click.argument('codename')
@click.argument('user')
@click.argument('client')
@click.pass_obj
def cli_role_users_add(obj: AppConfig, remote, course, codename: str, user: str):
def cli_role_users_add(obj: AppConfig, remote, course, codename: str, client: str):
    remote: Remote = helpers.get_remote(obj, remote)
    course = helpers.get_course(remote, course)
    helpers.generic_remove_client(course.roles, codename, user)
    helpers.generic_remove_client(course.roles, codename, client)



+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,17 @@ def cli_workers_read(obj: AppConfig, remote, codename: str):
    helpers.generic_read(remote.kontr_client.workers, codename)


@cli_workers.command('status', help='Get a worker status')
@click.option('-r', '--remote', required=False, help='Gets a worker status')
@click.argument('codename')
@click.pass_obj
def cli_workers_status(obj: AppConfig, remote, codename: str):
    remote: Remote = helpers.get_remote(obj, remote)
    worker = helpers.read_helper(remote.kontr_client.workers, codename)
    status = worker.status.read()
    helpers.entity_printer(status)


@cli_workers.command('delete', help='Delete worker')
@click.option('-r', '--remote', required=False, help='Sets remote')
@click.argument('codename')
@@ -52,3 +63,4 @@ def cli_workers_edit(obj: AppConfig, remote, codename: str):
def cli_workers_create(obj, remote, **kwargs):
    remote: Remote = helpers.get_remote(obj, remote)
    helpers.generic_create(remote.kontr_client.workers.create, **kwargs)
+3 −3
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ def generic_edit_create(create, params):
    return None


def generic_add_client(client, codename, user, client_type='user'):
def generic_add_client(client, codename, user, client_type=None):
    print(f"Adding client '{user}' from the {client.__class__.__name__} for {codename}")
    entity = read_helper(client, codename)
    entity.add_client(user, client_type=client_type)
@@ -158,7 +158,7 @@ def generic_add_client(client, codename, user, client_type='user'):
    entity_printer(entity)


def generic_add_users(client, codename, *users, client_type='user'):
def generic_add_users(client, codename, *users, client_type=None):
    print(f"Adding clients '{users}' from the {client.__class__.__name__} for {codename}")
    entity = read_helper(client, codename)
    entity.add_clients(*users, client_type=client_type)
@@ -166,7 +166,7 @@ def generic_add_users(client, codename, *users, client_type='user'):
    entity_printer(entity)


def generic_remove_client(client, codename, user, client_type='user'):
def generic_remove_client(client, codename, user, client_type=None):
    print(f"Removing client '{user}' from the {client.__class__.__name__}: {codename}")
    entity = read_helper(client, codename)
    entity.remove_client(user, client_type=client_type)