Rich Enhanced Shell History - Contextual shell history for zsh and bash
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
resh/common/resh-common.go

37 lines
817 B

package common
import (
"bytes"
"encoding/json"
"net/http"
"log"
)
type Record struct {
CmdLine string `json: cmdLine`
Pwd string `json: pwd`
GitWorkTree string `json: gitWorkTree`
Shell string `json: shell`
ExitCode int `json: exitCode`
Logs []string `json: logs`
}
func (r Record) Send() {
recJson, err := json.Marshal(r)
if err != nil {
log.Fatal("1 ", err)
}
req, err := http.NewRequest("POST", "http://localhost:8888",
bytes.NewBuffer(recJson))
if err != nil {
log.Fatal("2 ", err)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
_, err = client.Do(req)
if err != nil {
log.Fatal("resh-daemon is not running :(")
}
}