update
This commit is contained in:
@@ -39,7 +39,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
core.AddCommand([]core.Function{
|
core.AddCommand([]core.Function{
|
||||||
{
|
{
|
||||||
Rules: []string{`^env\s+([\S]*)$`},
|
Rules: []string{`^env\s+get\s+([\S]*)$`},
|
||||||
Handle: func(s im.Sender) interface{} {
|
Handle: func(s im.Sender) interface{} {
|
||||||
m := s.Get()
|
m := s.Get()
|
||||||
env, err := GetEnv(m)
|
env, err := GetEnv(m)
|
||||||
@@ -62,6 +62,24 @@ func init() {
|
|||||||
return nil
|
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+([^'"=]+)=['"]?([^=]+?)['"]?$`},
|
Rules: []string{`^export\s+([^'"=]+)=['"]?([^=]+?)['"]?$`, `^env\s+set\s+([^'"=]+)=['"]?([^=]+?)['"]?$`},
|
||||||
Handle: func(s im.Sender) interface{} {
|
Handle: func(s im.Sender) interface{} {
|
||||||
@@ -128,20 +146,17 @@ func req(ps ...interface{}) error {
|
|||||||
if strings.Contains(reflect.TypeOf(p).String(), "*") {
|
if strings.Contains(reflect.TypeOf(p).String(), "*") {
|
||||||
toParse = p
|
toParse = p
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(p, "--")
|
|
||||||
body, _ = json.Marshal(p)
|
body, _ = json.Marshal(p)
|
||||||
fmt.Println(string(body), "++")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var req *httplib.BeegoHTTPRequest
|
var req *httplib.BeegoHTTPRequest
|
||||||
api += apd
|
api += apd
|
||||||
|
|
||||||
switch method {
|
switch method {
|
||||||
case GET:
|
case GET:
|
||||||
req = httplib.Get(Config.Host + "/open/" + api)
|
req = httplib.Get(Config.Host + "/open/" + api)
|
||||||
case POST:
|
case POST:
|
||||||
req = httplib.Delete(Config.Host + "/open/" + api)
|
req = httplib.Post(Config.Host + "/open/" + api)
|
||||||
case DELETE:
|
case DELETE:
|
||||||
req = httplib.Delete(Config.Host + "/open/" + api)
|
req = httplib.Delete(Config.Host + "/open/" + api)
|
||||||
case PUT:
|
case PUT:
|
||||||
@@ -150,12 +165,11 @@ func req(ps ...interface{}) error {
|
|||||||
req.Header("Authorization", fmt.Sprintf("Bearer %s", token))
|
req.Header("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||||
req.Header("Content-Type", "application/json;charset=UTF-8")
|
req.Header("Content-Type", "application/json;charset=UTF-8")
|
||||||
if method != GET {
|
if method != GET {
|
||||||
|
|
||||||
req.Body(body)
|
req.Body(body)
|
||||||
}
|
}
|
||||||
fmt.Println(Config.Host + "/open/" + api)
|
// fmt.Println(Config.Host + "/open/" + api)
|
||||||
fmt.Println(method)
|
// fmt.Println(method)
|
||||||
fmt.Println(string(body))
|
// fmt.Println(string(body))
|
||||||
req.Body(body)
|
req.Body(body)
|
||||||
data, err := req.Bytes()
|
data, err := req.Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user