Skip to content

Commit

Permalink
feat: add limit option to ls (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
theletterjeff authored Nov 13, 2023
1 parent 7ee7aa8 commit c1d5ede
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion toggl/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ def get_entries(ctx, use_reports, **conditions):
help='Defines a set of fields of time entries, which will be displayed. It is also possible to modify '
'default set of fields using \'+\' and/or \'-\' characters. Supported values: '
+ types.FieldsType.format_fields_for_help(api.TimeEntry))
@click.option('--limit', '-n', type=int, help='The number of entries to display')
@click.pass_context
def entry_ls(ctx, fields, today, use_reports, **conditions):
def entry_ls(ctx, fields, today, use_reports, limit, **conditions):
"""
Lists time entries the user has access to.
Expand All @@ -239,6 +240,9 @@ def entry_ls(ctx, fields, today, use_reports, **conditions):

entities = get_entries(ctx, use_reports, **conditions)

if limit:
entities = entities[:limit]

if ctx.obj.get('simple'):
if ctx.obj.get('header'):
click.echo('\t'.join([click.style(field.capitalize(), **theme.header) for field in fields]))
Expand Down

0 comments on commit c1d5ede

Please sign in to comment.