Skip to content

Commit 54f1866

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

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
@@ -20,6 +20,7 @@ import (
2020
"github.com/lima-vm/lima/pkg/limatmpl"
2121
"github.com/lima-vm/lima/pkg/limayaml"
2222
networks "github.com/lima-vm/lima/pkg/networks/reconcile"
23+
"github.com/lima-vm/lima/pkg/registry"
2324
"github.com/lima-vm/lima/pkg/store"
2425
"github.com/lima-vm/lima/pkg/store/filenames"
2526
"github.com/lima-vm/lima/pkg/templatestore"
@@ -31,6 +32,7 @@ func registerCreateFlags(cmd *cobra.Command, commentPrefix string) {
3132
flags := cmd.Flags()
3233
flags.String("name", "", commentPrefix+"Override the instance name")
3334
flags.Bool("list-templates", false, commentPrefix+"List available templates and exit")
35+
flags.Bool("list-drivers", false, commentPrefix+"List available drivers and exit")
3436
editflags.RegisterCreate(cmd, commentPrefix)
3537
}
3638

@@ -53,6 +55,9 @@ $ limactl create --set='.cpus = 2 | .memory = "2GiB"'
5355
To see the template list:
5456
$ limactl create --list-templates
5557
58+
To see the drivers list:
59+
$ limactl create --list-drivers
60+
5661
To create an instance "default" from a local file:
5762
$ limactl create --name=default /usr/local/share/lima/templates/fedora.yaml
5863
@@ -391,6 +396,14 @@ func createStartActionCommon(cmd *cobra.Command, _ []string) (exit bool, err err
391396
}
392397
}
393398
return true, nil
399+
} else if listDrivers, err := cmd.Flags().GetBool("list-drivers"); err != nil {
400+
return true, err
401+
} else if listDrivers {
402+
w := cmd.OutOrStdout()
403+
for _, d := range registry.DefaultRegistry.List() {
404+
_, _ = fmt.Fprintln(w, d)
405+
}
406+
return true, nil
394407
}
395408
return false, nil
396409
}

0 commit comments

Comments
 (0)