Use -y option to confirm emptying failed queue by default

main
zhangliyong 10 years ago
parent c90da5336e
commit 1e5a8b58a1

@ -29,13 +29,19 @@ def main(ctx, url):
@main.command() @main.command()
@click.option('--yes', '-y', is_flag=True,
help='Empty failed queue by default')
@click.argument('queues', nargs=-1) @click.argument('queues', nargs=-1)
@click.pass_context @click.pass_context
def empty(ctx, queues): def empty(ctx, yes, queues):
"""[QUEUES]: queues to empty, default: failed queue """[QUEUES]: queues to empty
\b \b
$ rq empty $ rq empty
Do you want to empty failed queue? [y/N]: y
2 jobs removed from failed queue
\b
$ rq empty -y
2 jobs removed from failed queue 2 jobs removed from failed queue
\b \b
$ rq empty default high $ rq empty default high
@ -45,6 +51,8 @@ def empty(ctx, queues):
conn = ctx.obj['connection'] conn = ctx.obj['connection']
queues = [Queue(queue, connection=conn) for queue in queues] queues = [Queue(queue, connection=conn) for queue in queues]
if not queues: if not queues:
if yes or click.confirm('Do you want to empty failed queue?',
abort=True):
queues = (get_failed_queue(connection=conn),) queues = (get_failed_queue(connection=conn),)
for queue in queues: for queue in queues:
num_jobs = queue.empty() num_jobs = queue.empty()

Loading…
Cancel
Save