Skip to content

Commit

Permalink
Incus action support --console vga
Browse files Browse the repository at this point in the history
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 <nanjunjie@gmail.com>
  • Loading branch information
nanjj committed Jul 22, 2024
1 parent b7f6136 commit 6e8c269
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/incus/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down

0 comments on commit 6e8c269

Please sign in to comment.