# Path: alertaclient/utils.py
# def action_progressbar(client, action, ids, label, text=None, timeout=None):
#     skipped = 0
# 
#     def show_skipped(id):
#         if not id and skipped:
#             return f'(skipped {skipped})'
# 
#     with click.progressbar(ids, label=label, show_eta=True, item_show_func=show_skipped) as bar:
#         for id in bar:
#             try:
#                 client.action(id, action=action, text=text, timeout=timeout)
#             except Exception:
#                 skipped += 1
# 
# def build_query(filters):
#     return [tuple(f.split('=', 1)) for f in filters if '=' in f]


import click
from alertaclient.utils import action_progressbar, build_query



@click.command('unack', short_help='Un-acknowledge alerts')
@click.option('--ids', '-i', metavar='ID', multiple=True, help='List of alert IDs (can use short 8-char id)')
@click.option('--query', '-q', 'query', metavar='QUERY', help='severity:"warning" AND resource:web')

# Path: alertaclient/utils.py
# def action_progressbar(client, action, ids, label, text=None, timeout=None):
#     skipped = 0
# 
#     def show_skipped(id):
#         if not id and skipped:
#             return f'(skipped {skipped})'
# 
#     with click.progressbar(ids, label=label, show_eta=True, item_show_func=show_skipped) as bar:
#         for id in bar:
#             try:
#                 client.action(id, action=action, text=text, timeout=timeout)
#             except Exception:
#                 skipped += 1
# 
# def build_query(filters):
#     return [tuple(f.split('=', 1)) for f in filters if '=' in f]


# Path: alertaclient/commands/cmd_unack.py
import click
from alertaclient.utils import action_progressbar, build_query




@click.command('unack', short_help='Un-acknowledge alerts')
@click.option('--ids', '-i', metavar='ID', multiple=True, help='List of alert IDs (can use short 8-char id)')
@click.option('--query', '-q', 'query', metavar='QUERY', help='severity:"warning" AND resource:web')

@click.option('--filter', '-f', 'filters', metavar='FILTER', multiple=True, help='KEY=VALUE eg. serverity=warning resource=web')