Skip to content

Commit

Permalink
add a limit
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Jan 22, 2024
1 parent c3d64e0 commit c0f0ba3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions piccolo/apps/user/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
from piccolo.utils.printing import print_dict_table


def list_users():
def list_users(limit: int = 20):
"""
List existing users.
:param limit:
The maximum number of users to list.
"""
users = (
BaseUser.select(*BaseUser.all_columns(exclude=[BaseUser.password]))
.order_by(BaseUser.username)
.limit(limit)
.run_sync()
)

if len(users) < 1:
if len(users) == 0:
print("No data")
return

print_dict_table(users)
print_dict_table(users, header_separator=True)

0 comments on commit c0f0ba3

Please sign in to comment.