diff --git a/develop/qinglong/init.go b/develop/qinglong/init.go index 8147a64..1c39af6 100644 --- a/develop/qinglong/init.go +++ b/develop/qinglong/init.go @@ -39,7 +39,7 @@ func init() { } core.AddCommand([]core.Function{ { - Rules: []string{`^env\s+([\S]*)$`}, + Rules: []string{`^env\s+get\s+([\S]*)$`}, Handle: func(s im.Sender) interface{} { m := s.Get() env, err := GetEnv(m) @@ -62,6 +62,24 @@ func init() { return nil }, }, + { + Rules: []string{`^env\s+find\s+([\S]*)$`}, + Handle: func(s im.Sender) interface{} { + m := s.Get() + envs, err := GetEnvs(m) + if err != nil { + return err + } + if len(envs) == 0 { + return "未设置该环境变量" + } + es := []string{} + for _, env := range envs { + es = append(es, env.Value) + } + return strings.Join(es, "\n") + }, + }, { Rules: []string{`^export\s+([^'"=]+)=['"]?([^=]+?)['"]?$`, `^env\s+set\s+([^'"=]+)=['"]?([^=]+?)['"]?$`}, Handle: func(s im.Sender) interface{} { @@ -128,20 +146,17 @@ func req(ps ...interface{}) error { if strings.Contains(reflect.TypeOf(p).String(), "*") { toParse = p } else { - fmt.Println(p, "--") body, _ = json.Marshal(p) - fmt.Println(string(body), "++") } } } var req *httplib.BeegoHTTPRequest api += apd - switch method { case GET: req = httplib.Get(Config.Host + "/open/" + api) case POST: - req = httplib.Delete(Config.Host + "/open/" + api) + req = httplib.Post(Config.Host + "/open/" + api) case DELETE: req = httplib.Delete(Config.Host + "/open/" + api) case PUT: @@ -150,12 +165,11 @@ func req(ps ...interface{}) error { req.Header("Authorization", fmt.Sprintf("Bearer %s", token)) req.Header("Content-Type", "application/json;charset=UTF-8") if method != GET { - req.Body(body) } - fmt.Println(Config.Host + "/open/" + api) - fmt.Println(method) - fmt.Println(string(body)) + // fmt.Println(Config.Host + "/open/" + api) + // fmt.Println(method) + // fmt.Println(string(body)) req.Body(body) data, err := req.Bytes() if err != nil {