Change meaning of --jql in issues command

--jql can now provide filtering in addition to the other command line
arguments instead of replacing the whole query. This still allows the
same behavior as before by specifying none of the other options.
This commit is contained in:
MasterofJOKers 2022-10-25 22:26:57 +02:00
父節點 0ce3932e9c
當前提交 6c1667046b
共有 1 個文件被更改,包括 34 次插入37 次删除

查看文件

@ -98,8 +98,7 @@ def version(client):
@click.option('--flagged/--not-flagged', is_flag=True, default=None, help='Filter issues being flagged or not flagged')
@click.option('--order', help='Sort by this field')
@click.option('--asc/--desc', 'asc', help='Sort ascending/descending. Default: descending')
@click.option('--jql', default='', help='Provide your own JQL query to search for issues. '
'Setting this ignores all other query options except --project.')
@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):
@ -110,9 +109,11 @@ def issues(config, client, project, components, status, labels, texts, flagged,
# TODO add filtering by created since
# TODO add filtering by updated
# TODO support pagination I guess? i.e. a limit
if not jql:
filters = []
if jql:
filters.append(jql)
if texts:
texts_jql = ' AND '.join([f'text ~ "{text}"' for text in texts])
filters.append(f"( {texts_jql} )")
@ -151,10 +152,6 @@ def issues(config, client, project, components, status, labels, texts, flagged,
if order:
jql += f" ORDER BY {order} {'ASC' if asc else 'DESC'}"
else:
if project:
jql = f"project = {project} AND {jql}"
print(f"Searching with query: {jql}")
issues = client.search_issues(jql)
for issue in issues: