diff --git a/jiracli/cli.py b/jiracli/cli.py index 12b6d79..aa9eb70 100644 --- a/jiracli/cli.py +++ b/jiracli/cli.py @@ -91,7 +91,8 @@ def version(client): @main.command() @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('--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('--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') @@ -124,9 +125,14 @@ def issues(config, client, project, components, status, labels, texts, flagged, filters.append(components_jql) if status: - status_list = ', '.join([f'"{s}"' for s in status]) - status_jql = f"status IN ({status_list})" - filters.append(status_jql) + status_list = ', '.join([f'"{s}"' for s in status if not s.startswith('!')]) + if status_list: + 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: labels_jql = ' AND '.join([f'labels = "{label}"' for label in labels])