跳到主要内容

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

浏览文件

editorcmd.go

49 行 · 1.2 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4// From https://raw.githubusercontent.com/norouter/norouter/v0.6.5/cmd/norouter/editorcmd/editorcmd.go
5/*
6 Copyright (C) NoRouter authors.
7
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19*/
20
21package editorcmd
22
23import (
24 "os"
25 "os/exec"
26)
27
28// Detect detects a text editor command.
29// Returns an empty string when no editor is found.
30func Detect() string {
31 candidates := []string{
32 os.Getenv("VISUAL"),
33 os.Getenv("EDITOR"),
34 "editor",
35 "vim",
36 "vi",
37 "emacs",
38 }
39 for _, f := range candidates {
40 if f == "" {
41 continue
42 }
43 x, err := exec.LookPath(f)
44 if err == nil {
45 return x
46 }
47 }
48 return ""
49}