1 Star 1 Fork 1

mjun1833 / delve

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
config.go 2.74 KB
一键复制 编辑 原始数据 按行查看 历史
majun 提交于 2023-08-24 16:44 . chore: update module name
package dap
import (
"bytes"
"fmt"
"strings"
"gitee.com/mjun1833/delve/pkg/config"
)
func listConfig(args *launchAttachArgs) string {
var buf bytes.Buffer
config.ConfigureList(&buf, args, "cfgName")
return buf.String()
}
func configureSet(sargs *launchAttachArgs, args string) (bool, string, error) {
v := config.Split2PartsBySpace(args)
cfgname := v[0]
var rest string
if len(v) == 2 {
rest = v[1]
}
field := config.ConfigureFindFieldByName(sargs, cfgname, "cfgName")
if !field.CanAddr() {
return false, "", fmt.Errorf("%q is not a configuration parameter", cfgname)
}
if cfgname == "substitutePath" {
err := configureSetSubstitutePath(sargs, rest)
if err != nil {
return false, "", err
}
// Print the updated client to server and server to client maps.
return true, config.ConfigureListByName(sargs, cfgname, "cfgName"), nil
}
err := config.ConfigureSetSimple(rest, cfgname, field)
if err != nil {
return false, "", err
}
return true, config.ConfigureListByName(sargs, cfgname, "cfgName"), nil
}
func configureSetSubstitutePath(args *launchAttachArgs, rest string) error {
if strings.TrimSpace(rest) == "-clear" {
args.substitutePathClientToServer = args.substitutePathClientToServer[:0]
args.substitutePathServerToClient = args.substitutePathServerToClient[:0]
return nil
}
argv := config.SplitQuotedFields(rest, '"')
if len(argv) == 2 && argv[0] == "-clear" {
argv = argv[1:]
}
switch len(argv) {
case 0:
// do nothing, let caller show the current list of substitute path rules
return nil
case 1: // delete substitute-path rule
for i := range args.substitutePathClientToServer {
if args.substitutePathClientToServer[i][0] == argv[0] {
copy(args.substitutePathClientToServer[i:], args.substitutePathClientToServer[i+1:])
args.substitutePathClientToServer = args.substitutePathClientToServer[:len(args.substitutePathClientToServer)-1]
copy(args.substitutePathServerToClient[i:], args.substitutePathServerToClient[i+1:])
args.substitutePathServerToClient = args.substitutePathServerToClient[:len(args.substitutePathServerToClient)-1]
return nil
}
}
return fmt.Errorf("could not find rule for %q", argv[0])
case 2: // add substitute-path rule
for i := range args.substitutePathClientToServer {
if args.substitutePathClientToServer[i][0] == argv[0] {
args.substitutePathClientToServer[i][1] = argv[1]
args.substitutePathServerToClient[i][0] = argv[1]
return nil
}
}
args.substitutePathClientToServer = append(args.substitutePathClientToServer, [2]string{argv[0], argv[1]})
args.substitutePathServerToClient = append(args.substitutePathServerToClient, [2]string{argv[1], argv[0]})
default:
return fmt.Errorf("too many arguments to \"config substitutePath\"")
}
return nil
}
Go
1
https://gitee.com/mjun1833/delve.git
git@gitee.com:mjun1833/delve.git
mjun1833
delve
delve
v1.21.1

搜索帮助