Debian Codegraph @

docs/plugins/limit.rst

raw
1 Limit Query Plugin
2 ==================
3
4 .. deprecated:: 2.14
5
6 Use the built-in ``-l`` / ``--limit`` flag on the :ref:`list-cmd` command
7 instead.
8
9 ``limit`` is a plugin to limit a query to the first or last set of results. We
10 also provide a query prefix ``'<n'`` to inline the same behavior in the ``list``
11 command. They are analogous to piping results:
12
13 $ beet [list|ls] [QUERY] | [head|tail] -n n
14
15 There are two provided interfaces:
16
17 1. ``beet lslimit [--head n | --tail n] [QUERY]`` returns the head or tail of a
18 query
19
20 2. ``beet [list|ls] [QUERY] '<n'`` returns the head of a query
21
22 There are two differences in behavior:
23
24 1. The query prefix does not support tail.
25
26 2. The query prefix could appear anywhere in the query but will only have the
27 same behavior as the ``lslimit`` command and piping to ``head`` when it appears
28 last.
29
30 Performance for the query previx is much worse due to the current
31 singleton-based implementation.
32
33 So why does the query prefix exist? Because it composes with any other
34 query-based API or plugin (see :doc:`/reference/query`). For example, you can
35 use the query prefix in ``smartplaylist`` (see :doc:`/plugins/smartplaylist`) to
36 limit the number of tracks in a smart playlist for applications like most played
37 and recently added.
38
39 Configuration
40 -------------
41
42 Enable the ``limit`` plugin in your configuration (see :ref:`using-plugins`).
43
44 Examples
45 --------
46
47 First 10 tracks
48
49 .. code-block:: sh
50
51 $ beet ls | head -n 10
52 $ beet lslimit --head 10
53 $ beet ls '<10'
54
55 Last 10 tracks
56
57 .. code-block:: sh
58
59 $ beet ls | tail -n 10
60 $ beet lslimit --tail 10
61
62 100 mostly recently released tracks
63
64 .. code-block:: sh
65
66 $ beet lslimit --head 100 year- month- day-
67 $ beet ls year- month- day- '<100'
68 $ beet lslimit --tail 100 year+ month+ day+