From 11eb0f11e4d5c698d41f7dfba6971a5de0ee1200 Mon Sep 17 00:00:00 2001 From: JUN JIE NAN Date: Fri, 19 Jul 2024 20:57:11 +0800 Subject: [PATCH] Incus action support --console vga Supports below usage: 1. incus start --console, 2. incus start --console=vga, 3. incus start --console vga # my favor one Signed-off-by: JUN JIE NAN --- cmd/incus/action.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/incus/action.go b/cmd/incus/action.go index ddb2f502200..a4ff99a80f6 100644 --- a/cmd/incus/action.go +++ b/cmd/incus/action.go @@ -430,6 +430,19 @@ func (c *cmdAction) Run(cmd *cobra.Command, args []string) error { return fmt.Errorf(i18n.G("--console can't be used with --all")) } + if len(names) > 1 { + idx := slices.Index(names, "vga") + idx2 := slices.Index(names, "console") + if idx == -1 || (idx2 != -1 && idx > idx2) { + idx = idx2 + } + + if idx != -1 { + c.flagConsole = names[idx] + names = append(names[0:idx], names[idx+1:]...) + } + } + if len(names) != 1 { return fmt.Errorf(i18n.G("--console only works with a single instance")) }