跳到主要内容

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

浏览文件

yq.go

47 行 · 1.1 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4// SPDX-FileCopyrightText: Copyright (c) 2017 Mike Farah
5
6// This file has been adapted from https://github.com/mikefarah/yq/blob/v4.47.1/yq.go
7
8package yq
9
10import (
11 "os"
12 "path/filepath"
13 "strings"
14
15 command "github.com/mikefarah/yq/v4/cmd"
16)
17
18func main() {
19 cmd := command.New()
20 args := os.Args[1:]
21 _, _, err := cmd.Find(args)
22 if err != nil && args[0] != "__complete" {
23 // default command when nothing matches...
24 newArgs := []string{"eval"}
25 cmd.SetArgs(append(newArgs, os.Args[1:]...))
26 }
27 code := 0
28 if err := cmd.Execute(); err != nil {
29 code = 1
30 }
31 os.Exit(code)
32}
33
34// MaybeRunYQ runs as `yq` if the program name or first argument is `yq`.
35// Only returns to caller if os.Args doesn't contain a `yq` command.
36func MaybeRunYQ() {
37 progName := filepath.Base(os.Args[0])
38 // remove all extensions, so we match "yq.lima.exe"
39 progName, _, _ = strings.Cut(progName, ".")
40 if progName == "yq" {
41 main()
42 }
43 if len(os.Args) > 1 && os.Args[1] == "yq" {
44 os.Args = os.Args[1:]
45 main()
46 }
47}