Support NOT in --status of issues

This commit is contained in:
MasterofJOKers 2022-09-20 22:56:31 +02:00
parent 471855beb6
commit 6e2d639034
1 changed files with 10 additions and 4 deletions

View File

@ -91,7 +91,8 @@ def version(client):
@main.command() @main.command()
@click.option('--project', help='Project to filter for. Default: take from config [filters]/default_project') @click.option('--project', help='Project to filter for. Default: take from config [filters]/default_project')
@click.option('--component', 'components', multiple=True, help='Filter for issues with *any* of the given components') @click.option('--component', 'components', multiple=True, help='Filter for issues with *any* of the given components')
@click.option('--status', multiple=True, help='Filter for issues with *any* of the given statuses') @click.option('--status', multiple=True, help='Filter for issues with *any* of the given statuses. '
'! at the beginning means NOT.')
@click.option('--label', 'labels', multiple=True, help='Filter for issues with all the given labels') @click.option('--label', 'labels', multiple=True, help='Filter for issues with all the given labels')
@click.option('--text', 'texts', multiple=True, help='Filter for issues containing all the given strings') @click.option('--text', 'texts', multiple=True, help='Filter for issues containing all the given strings')
@click.option('--flagged/--not-flagged', is_flag=True, default=None, help='Filter issues being flagged or not flagged') @click.option('--flagged/--not-flagged', is_flag=True, default=None, help='Filter issues being flagged or not flagged')
@ -124,9 +125,14 @@ def issues(config, client, project, components, status, labels, texts, flagged,
filters.append(components_jql) filters.append(components_jql)
if status: if status:
status_list = ', '.join([f'"{s}"' for s in status]) status_list = ', '.join([f'"{s}"' for s in status if not s.startswith('!')])
status_jql = f"status IN ({status_list})" if status_list:
filters.append(status_jql) status_jql = f"status IN ({status_list})"
filters.append(status_jql)
status_list = ', '.join([f'"{s[1:]}"' for s in status if s.startswith('!')])
if status_list:
status_jql = f"status NOT IN ({status_list})"
filters.append(status_jql)
if labels: if labels:
labels_jql = ' AND '.join([f'labels = "{label}"' for label in labels]) labels_jql = ' AND '.join([f'labels = "{label}"' for label in labels])