Skip to content

Commit d902724

Browse files
committed
Incus action support --console vga
Supports below usage: 1. incus start <instance> --console, 2. incus start <instance> --console=vga, 3. incus start <instance> --console vga # my favor one Signed-off-by: JUN JIE NAN <[email protected]>
1 parent 65ac8ef commit d902724

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmd/incus/action.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,19 @@ func (c *cmdAction) Run(cmd *cobra.Command, args []string) error {
430430
return fmt.Errorf(i18n.G("--console can't be used with --all"))
431431
}
432432

433+
if len(names) > 1 {
434+
idx := slices.Index(names, "vga")
435+
idx2 := slices.Index(names, "console")
436+
if idx == -1 || (idx2 != -1 && idx > idx2) {
437+
idx = idx2
438+
}
439+
440+
if idx != -1 {
441+
c.flagConsole = names[idx]
442+
names = append(names[0:idx], names[idx+1:]...)
443+
}
444+
}
445+
433446
if len(names) != 1 {
434447
return fmt.Errorf(i18n.G("--console only works with a single instance"))
435448
}

0 commit comments

Comments
 (0)