chore: support 0 arg l command

This commit is contained in:
0x1a8510f2 2023-06-19 22:30:31 +01:00
parent e160060f2b
commit 70048662f5
Signed by: 0x1a8510f2
GPG Key ID: 1C692E355D76775D

View File

@ -47,10 +47,19 @@ func CmdX(ctx lib.CommandContext, arg string) (string, error) {
}
func CmdL(ctx lib.CommandContext, arg string) (string, error) {
page, err := strconv.Atoi(arg)
if err != nil {
return "", fmt.Errorf("could not parse argument: %e", err)
var (
page int
err error
)
if arg == "" {
page = 0
} else {
page, err = strconv.Atoi(arg)
if err != nil {
return "", fmt.Errorf("could not parse argument: %e", err)
}
}
clients, err := ctx.State.ClientGetPage(page*lib.DATA_PAGE_SIZE, lib.DATA_PAGE_SIZE)
if err != nil {
return "", fmt.Errorf("could not get page from database: %e", err)