# Path: alertaclient/utils.py
# def build_query(filters):
#     return [tuple(f.split('=', 1)) for f in filters if '=' in f]


import click
from alertaclient.utils import build_query
@click.option('--delete', '-D', metavar='ID', nargs=2, help='Delete note, using alert ID and note ID')
@click.pass_obj
def cli(obj, alert_ids, query, filters, text, delete):
    """
    Add or delete note to alerts.

    EXAMPLES

        Add a note to an alert.

            $ alerta note --alert-ids <alert-id> --text <note>

        List notes for an alert.

            $ alerta notes --alert-ids <alert-id>

        Delete a note for an alert.

            $ alerta note -D <alert-id> <note-id>
    """
    client = obj['client']
    if delete:
        client.delete_alert_note(*delete)
    else:
        if alert_ids:
            total = len(alert_ids)
        else:
            if query:
                query = [('q', query)]
            else:

# Path: alertaclient/utils.py
# def build_query(filters):
#     return [tuple(f.split('=', 1)) for f in filters if '=' in f]


# Path: alertaclient/commands/cmd_note.py
import click
from alertaclient.utils import build_query

@click.option('--delete', '-D', metavar='ID', nargs=2, help='Delete note, using alert ID and note ID')
@click.pass_obj
def cli(obj, alert_ids, query, filters, text, delete):
    """
    Add or delete note to alerts.

    EXAMPLES

        Add a note to an alert.

            $ alerta note --alert-ids <alert-id> --text <note>

        List notes for an alert.

            $ alerta notes --alert-ids <alert-id>

        Delete a note for an alert.

            $ alerta note -D <alert-id> <note-id>
    """
    client = obj['client']
    if delete:
        client.delete_alert_note(*delete)
    else:
        if alert_ids:
            total = len(alert_ids)
        else:
            if query:
                query = [('q', query)]
            else:

                query = build_query(filters)