Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing multiple entities with single command #95

Open
AuHau opened this issue Jan 21, 2019 · 3 comments
Open

Removing multiple entities with single command #95

AuHau opened this issue Jan 21, 2019 · 3 comments

Comments

@AuHau
Copy link
Owner

AuHau commented Jan 21, 2019

Currently, all rm subcommands accept only one ID/Name, it would be more user-friendly if they would accept "infinite" number of arguments.

@dkvc
Copy link
Contributor

dkvc commented Feb 18, 2023

I think this can be done by making the argument spec as variadic argument (accepting infinte arguments and setting it as required such that at least one arg is required.). Then iterating through all values, removing them one by one.

[...]
@click.argument('spec', nargs=-1, required=True)
[...]
    for sp in spec:
         helpers.entity_remove(api.TimeEntry, sp, ('id', 'description'), obj=ctx.obj)
[...]

While this implementation prevents breaking previous versions, it has an issue. If one of the amidst time entry doesn't exist, the program halts. Is there any way to prevent this issue?

@StanczakDominik
Copy link
Collaborator

How exactly does it halt? Does it just throw an exception? Can't you wrap that in a try/except block?

@dkvc
Copy link
Contributor

dkvc commented Feb 24, 2023

In entity remove, this line halts the program if entry is not found.

[...]
def entity_remove():
[...]
    if not entities:
        click.echo('{} not found!'.format(cls.get_name(verbose=True)), color=theme.error_color)
        exit(44)
[...]

While exit(44) can be removed, the terminal returns exit status 0 even if not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants