Skip to content

Commit 535a080

Browse files
committed
driver(internal): list available built-in drivers
Signed-off-by: Ansuman Sahoo <[email protected]>
1 parent f02c49b commit 535a080

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmd/limactl/start.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/lima-vm/lima/pkg/limatmpl"
2222
"github.com/lima-vm/lima/pkg/limayaml"
2323
networks "github.com/lima-vm/lima/pkg/networks/reconcile"
24+
"github.com/lima-vm/lima/pkg/registry"
2425
"github.com/lima-vm/lima/pkg/store"
2526
"github.com/lima-vm/lima/pkg/store/filenames"
2627
"github.com/lima-vm/lima/pkg/templatestore"
@@ -32,6 +33,7 @@ func registerCreateFlags(cmd *cobra.Command, commentPrefix string) {
3233
flags := cmd.Flags()
3334
flags.String("name", "", commentPrefix+"Override the instance name")
3435
flags.Bool("list-templates", false, commentPrefix+"List available templates and exit")
36+
flags.Bool("list-drivers", false, commentPrefix+"List available drivers and exit")
3537
editflags.RegisterCreate(cmd, commentPrefix)
3638
}
3739

@@ -54,6 +56,9 @@ $ limactl create --set='.cpus = 2 | .memory = "2GiB"'
5456
To see the template list:
5557
$ limactl create --list-templates
5658
59+
To see the drivers list:
60+
$ limactl create --list-drivers
61+
5762
To create an instance "default" from a local file:
5863
$ limactl create --name=default /usr/local/share/lima/templates/fedora.yaml
5964
@@ -393,6 +398,14 @@ func createStartActionCommon(cmd *cobra.Command, _ []string) (exit bool, err err
393398
_, _ = fmt.Fprintln(w, f.Name)
394399
}
395400
return true, nil
401+
} else if listDrivers, err := cmd.Flags().GetBool("list-drivers"); err != nil {
402+
return true, err
403+
} else if listDrivers {
404+
w := cmd.OutOrStdout()
405+
for _, d := range registry.DefaultRegistry.List() {
406+
_, _ = fmt.Fprintln(w, d)
407+
}
408+
return true, nil
396409
}
397410
return false, nil
398411
}

0 commit comments

Comments
 (0)