Files
devvm/internal/cli/host.go
T
2026-11-06 06:16:29 -07:00

34 lines
1.1 KiB
Go

package cli
import (
"github.com/spf13/cobra"
"github.com/devvmhq/devvm/internal/msg"
"github.com/devvmhq/devvm/internal/vm"
)
// newHostCmd is devvm host [--ssh-config].
func newHostCmd(a *app) *cobra.Command {
var include bool
cmd := &cobra.Command{
Use: "host",
Short: "Get this folder's VM ready for ssh and editors, and show its host name",
Long: "Get this folder's VM ready for ssh and editors as devvm does before it opens a shell, starting the VM if it's stopped. " +
"Then show the host name that ssh and VS Code's Remote-SSH reach it by, such as devvm-website for a folder named website.",
Example: examples(
"devvm host", "get the VM ready and show its host name",
"ssh devvm-website", "then connect by that name, for a folder named website",
),
Args: noArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
return a.env(func(env *vm.Env) error {
env.AddInclude = include
return vm.Launch{Env: env}.ShowHost(cmd.Context())
}, msg.SSHFailed)
},
}
addSSHConfigFlag(cmd.Flags(), &include)
addFolderFlags(cmd, a)
return cmd
}