Files
devvm/internal/cli/code.go
T
w3cjandClaude Opus 5.5 3e81767482 refactor(cli): each command carries its own docs link, group and samples
A command's metadata moves from hand-kept tables into the command itself:
an about (docs page, help group, why no --json) set as its Cobra
Annotations. msg.commandDocs, commandGroups and withoutJSON are gone;
TestDocLinks reads the links from the generated CLI reference, and help
output and the reference are byte-identical. AGENTS.md's cli and vm rows
point at new doc.go package comments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:05:13 -07:00

38 lines
1.0 KiB
Go

package cli
import (
"github.com/spf13/cobra"
"github.com/devvmhq/devvm/internal/msg"
"github.com/devvmhq/devvm/internal/vm"
)
// newCodeCmd is devvm code.
func newCodeCmd(a *app) *cobra.Command {
var include bool
cmd := &cobra.Command{
Use: "code",
Annotations: about{
docs: "using/ssh#vs-code", group: groupVM,
noJSON: "it opens VS Code",
}.annotations(),
Short: "Open this folder's VM in VS Code over Remote-SSH",
Long: "Get this folder's VM ready as devvm host does, then open its folder in VS Code over Remote-SSH, " +
"with VS Code's code command.",
Example: examples(
"devvm code", "open this folder's VM in VS Code",
"devvm code --ssh-config", "the same, adding devvm's Include line to ~/.ssh/config without asking",
),
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}.Code(cmd.Context())
}, msg.CodeFailed)
},
}
addSSHConfigFlag(cmd.Flags(), &include)
addFolderFlags(cmd, a)
return cmd
}