Add a filter for watched issues

This commit is contained in:
MasterofJOKers 2022-10-25 22:37:32 +02:00
parent 6596be6c1e
commit 68b1142cd7
1 changed files with 9 additions and 1 deletions

View File

@ -96,12 +96,13 @@ def version(client):
@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')
@click.option('--watching/--not-watching', is_flag=True, default=None, help='Filter issues I watch or do not watch')
@click.option('--order', help='Sort by this field')
@click.option('--asc/--desc', 'asc', help='Sort ascending/descending. Default: descending')
@click.option('--jql', help='Provide your own JQL query string to include in the search via AND.')
@pass_client
@pass_config
def issues(config, client, project, components, status, labels, texts, flagged, order, asc, jql):
def issues(config, client, project, components, status, labels, texts, flagged, watching, order, asc, jql):
if project is None and config.has_section('filters') and config.get('filters', 'default_project'):
project = config['filters']['default_project']
@ -143,6 +144,13 @@ def issues(config, client, project, components, status, labels, texts, flagged,
flagged_jql = 'flagged IS EMPTY'
filters.append(flagged_jql)
if watching is not None:
if watching:
watching_jql = 'watcher = currentUser()'
else:
watching_jql = 'watcher != currentUser()'
filters.append(watching_jql)
if project:
project_jql = f"project = {project}"
filters.append(project_jql)