From d140fc6807e7942ab742b5da92776938b59ba1d3 Mon Sep 17 00:00:00 2001 From: Jeff Martin Date: Sun, 29 Oct 2023 10:56:38 -0400 Subject: [PATCH] feat: add limit option to ls --- toggl/cli/commands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/toggl/cli/commands.py b/toggl/cli/commands.py index 0356cc5..60dd609 100644 --- a/toggl/cli/commands.py +++ b/toggl/cli/commands.py @@ -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. @@ -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]))