Skip to content

Commit

Permalink
Add an --extract-id option
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Oct 3, 2023
1 parent a0b3da6 commit 6f6baff
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bioluigi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def format_status(status):
def format(self, task):
raise NotImplementedError

class ExtractingIdTaskFormatter(TaskFormatter):
def format(self, task):
return task['id'] + '\n'

class ExtractingParameterTaskFormatter(TaskFormatter):
def __init__(self, field):
self.field = field
Expand Down Expand Up @@ -138,9 +142,10 @@ def main():
@click.option('--user', multiple=True)
@click.option('--summary', is_flag=True)
@click.option('--detailed', is_flag=True)
@click.option('--extract-id', is_flag=True)
@click.option('--extract-parameter')
@click.option('--no-limit', is_flag=True)
def list(task_glob, status, user, summary, detailed, extract_parameter, no_limit):
def list(task_glob, status, user, summary, detailed, extract_id, extract_parameter, no_limit):
"""
List all tasks that match the given pattern and filters.
"""
Expand Down Expand Up @@ -185,7 +190,9 @@ def list(task_glob, status, user, summary, detailed, extract_parameter, no_limit
formatter = TasksSummaryFormatter()
click.echo(formatter.format(filtered_tasks))
else:
if extract_parameter:
if extract_id:
formatter = ExtractingIdTaskFormatter()
elif extract_parameter:
formatter = ExtractingParameterTaskFormatter(field=extract_parameter)
elif detailed:
formatter = DetailedTaskFormatter()
Expand Down

0 comments on commit 6f6baff

Please sign in to comment.