跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

autostart.go

56 行 · 1.6 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package main
5
6import (
7 "github.com/spf13/cobra"
8)
9
10func newAutostartCommand() *cobra.Command {
11 autostartCommand := &cobra.Command{
12 Use: "autostart",
13 Short: "Manage automatic startup of Lima instances",
14 GroupID: advancedCommand,
15 }
16 autostartCommand.AddCommand(newAutostartEnableCommand(), newAutostartDisableCommand())
17 return autostartCommand
18}
19
20func newAutostartEnableCommand() *cobra.Command {
21 cmd := &cobra.Command{
22 Use: "enable INSTANCE",
23 Short: "Register an instance to start automatically",
24 Args: WrapArgsError(cobra.ExactArgs(1)),
25 RunE: autostartEnableAction,
26 ValidArgsFunction: autostartComplete,
27 }
28 flags := cmd.Flags()
29 flags.String(
30 "condition", "login",
31 "When to start the instance: \"login\" (user session) or \"boot\" (system boot, macOS only)",
32 )
33 flags.String(
34 "user", "",
35 "macOS username to run the instance as when --condition=boot (default: $USER)",
36 )
37 flags.Bool(
38 "keep-alive", true,
39 "Restart the instance automatically if the host agent exits unexpectedly",
40 )
41 return cmd
42}
43
44func newAutostartDisableCommand() *cobra.Command {
45 return &cobra.Command{
46 Use: "disable INSTANCE",
47 Short: "Unregister an instance from automatic startup",
48 Args: WrapArgsError(cobra.ExactArgs(1)),
49 RunE: autostartDisableAction,
50 ValidArgsFunction: autostartComplete,
51 }
52}
53
54func autostartComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
55 return bashCompleteInstanceNames(cmd)
56}