api.listdir: fix check for empty query values to accept zeroes

Not sure why it's there at all - probably to guard vs stray None or
similar things.
cli.ls: add --range option