Files
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

39 lines
1.5 KiB
Go

package cli
import (
"github.com/spf13/cobra"
"github.com/devvmhq/devvm/internal/msg"
"github.com/devvmhq/devvm/internal/vm"
)
// newDesktopCmd is devvm desktop.
func newDesktopCmd(a *app) *cobra.Command {
var o vm.DesktopOptions
c := &cobra.Command{
Use: "desktop",
Annotations: about{
docs: "using/desktop", group: groupVM,
noJSON: "it opens a VNC viewer, or shows the address and password to type into one",
}.annotations(),
Short: "Open this folder's VM's desktop in a VNC viewer",
Long: "Start the desktop of this folder's VM, which needs the desktop layer, and serve it on " +
"this machine's 127.0.0.1 with a password of the VM's own until you press Ctrl+C or the VM stops. " +
"On macOS, Screen Sharing opens it and asks for the password, which devvm shows.",
Example: examples(
"devvm desktop", "open the VM's desktop in Screen Sharing",
"devvm desktop --clipboard", "the same, sharing the clipboard both ways",
"devvm desktop --no-open", "show the address and password for a VNC viewer of your own",
),
Args: noArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
return a.env(func(env *vm.Env) error { return vm.Desktop{Env: env}.Open(cmd.Context(), o) }, msg.DesktopFailed)
},
}
f := c.Flags()
f.BoolVar(&o.Clipboard, "clipboard", false, "share the clipboard between this machine and the VM, both ways")
f.BoolVar(&o.NoOpen, "no-open", false, "show the address and password without opening Screen Sharing")
addFolderFlags(c, a)
return c
}