mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
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]>
40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/devvmhq/devvm/internal/msg"
|
|
"github.com/devvmhq/devvm/internal/vm"
|
|
)
|
|
|
|
// newAdoptCmd is devvm adopt [VM] [--force].
|
|
func newAdoptCmd(a *app) *cobra.Command {
|
|
var force bool
|
|
cmd := &cobra.Command{
|
|
Use: "adopt [VM]",
|
|
Annotations: about{
|
|
docs: "using/vms#a-folder-made-again", group: groupVM,
|
|
noJSON: "it changes which folder a VM is for",
|
|
}.annotations(),
|
|
Short: "Give this folder the VM made for an earlier folder or path",
|
|
Long: "Give this folder the VM made for an earlier folder at this path, or for this folder before you moved or renamed it, with its files, secrets and allowlist. " +
|
|
"With VM, its name as devvm ls lists it, devvm moves that VM here from a folder that's gone, such as one you copied to another disk. " +
|
|
"devvm asks first in a terminal without --no-input.",
|
|
Example: examples(
|
|
"devvm adopt", "give this folder the VM, after asking",
|
|
"devvm adopt --force", "give it without asking, as a script must",
|
|
"devvm adopt devvm-web-71a99b1076d92c", "move that VM here from a folder that's gone, after asking",
|
|
),
|
|
Args: maxArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
name := ""
|
|
if len(args) == 1 {
|
|
name = args[0]
|
|
}
|
|
return a.env(func(env *vm.Env) error { return vm.Lifecycle{Env: env}.Adopt(cmd.Context(), name, force) }, msg.AdoptFailed)
|
|
},
|
|
}
|
|
addForceFlag(cmd.Flags(), &force)
|
|
return cmd
|
|
}
|