2026-01-30 00:22:47 +00:00
|
|
|
// Package vm provides LinuxKit VM management commands.
|
|
|
|
|
package vm
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
|
|
|
"github.com/host-uk/core/cmd/shared"
|
2026-01-30 00:47:54 +00:00
|
|
|
"github.com/spf13/cobra"
|
2026-01-30 00:22:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Style aliases from shared
|
|
|
|
|
var (
|
|
|
|
|
repoNameStyle = shared.RepoNameStyle
|
|
|
|
|
successStyle = shared.SuccessStyle
|
|
|
|
|
errorStyle = shared.ErrorStyle
|
|
|
|
|
dimStyle = shared.DimStyle
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// VM-specific styles
|
|
|
|
|
var (
|
|
|
|
|
varStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#f59e0b"))
|
|
|
|
|
defaultStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#6b7280")).Italic(true)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// AddVMCommands adds container-related commands under 'vm' to the CLI.
|
2026-01-30 00:47:54 +00:00
|
|
|
func AddVMCommands(root *cobra.Command) {
|
|
|
|
|
vmCmd := &cobra.Command{
|
|
|
|
|
Use: "vm",
|
|
|
|
|
Short: "LinuxKit VM management",
|
|
|
|
|
Long: "Manage LinuxKit virtual machines.\n\n" +
|
|
|
|
|
"LinuxKit VMs are lightweight, immutable VMs built from YAML templates.\n" +
|
|
|
|
|
"They run using qemu or hyperkit depending on your system.\n\n" +
|
|
|
|
|
"Commands:\n" +
|
|
|
|
|
" run Run a VM from image or template\n" +
|
|
|
|
|
" ps List running VMs\n" +
|
|
|
|
|
" stop Stop a running VM\n" +
|
|
|
|
|
" logs View VM logs\n" +
|
|
|
|
|
" exec Execute command in VM\n" +
|
|
|
|
|
" templates Manage LinuxKit templates",
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
root.AddCommand(vmCmd)
|
2026-01-30 00:22:47 +00:00
|
|
|
addVMRunCommand(vmCmd)
|
|
|
|
|
addVMPsCommand(vmCmd)
|
|
|
|
|
addVMStopCommand(vmCmd)
|
|
|
|
|
addVMLogsCommand(vmCmd)
|
|
|
|
|
addVMExecCommand(vmCmd)
|
|
|
|
|
addVMTemplatesCommand(vmCmd)
|
|
|
|
|
}
|