Skip to content

Conversation

@jandubois
Copy link
Member

This is mostly useful for selection, so e.g. a plugin can select all running instances, and an option to the plugin can narrow down the selection further, or select fields etc.

This change also make the --quiet option compatible with --yq. Before --quiet took precedence and --yq was ignored instead of generated an incompatibility warning. Now --quiet works with --yq by passing the final result through | .name, which implements the same functionality it normally has.

Examples:

l ls
NAME       STATUS     SSH                VMTYPE    ARCH       CPUS    MEMORY    DISK      DIR
bar        Stopped    127.0.0.1:0        vz        aarch64    4       4GiB      100GiB    ~/.lima/bar
clone      Stopped    127.0.0.1:0        vz        aarch64    4       4GiB      100GiB    ~/.lima/clone
default    Stopped    127.0.0.1:0        vz        aarch64    4       4GiB      100GiB    ~/.lima/default
docker     Running    127.0.0.1:60763    vz        aarch64    4       4GiB      100GiB    ~/.lima/docker
qemu       Running    127.0.0.1:63754    qemu      aarch64    4       4GiB      100GiB    ~/.lima/qemul ls -q
bar
clone
default
docker
qemul ls --yq 'select(.config.vmType == "vz").name'
bar
clone
default
dockerl ls --yq 'select(.config.vmType == "vz")' -q
bar
clone
default
dockerl ls --yq 'select(.config.vmType == "vz")' --yq 'select(.status == "Running")' -q
docker

BTW, I find --quiet a bit of a weird choice for "display only the names of the instances", but I guess we copied it from docker ps --quiet.

This is mostly useful for selection, so e.g. a plugin can select all
running instances, and an option to the plugin can narrow down the
selection further, or select fields etc.

This change also make the `--quiet` option compatible with `--yq`.
Before `--quiet` took precedence and `--yq` was ignored instead of
generated an incompatibility warning. Now `--quiet` works with `--yq`
by passing the final result through ` | .name`, which implements the
same functionality it normally has.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
@AkihiroSuda
Copy link
Member

Can we have bats tests?

@jandubois
Copy link
Member Author

Can we have bats tests?

Yes, of course. I have bats 0-yq.bats and 1-list.bats in progress because these are foundational for the later tests, and these changes will go into 1-list.bats. I can bundle these 2 bats tests with this PR, if you want, but they are not quite ready yet.

@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Sep 9, 2025
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 2105d57 into lima-vm:master Sep 9, 2025
36 checks passed
@jandubois jandubois deleted the list-yq-improve branch September 9, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants