remove recall

pull/184/head
Simon Let 4 years ago committed by Simon Let
parent 7e3e72d957
commit d4367ee88f
  1. 36
      .goreleaser.yml
  2. 2
      Makefile
  3. 151
      cmd/collect/main.go
  4. 35
      pkg/collect/collect.go
  5. 2
      roadmap.md

@ -75,33 +75,6 @@ builds:
- amd64 - amd64
- arm - arm
- arm64 - arm64
-
id: "evaluate"
main: ./cmd/evaluate
binary: bin/resh-evaluate
goarch:
- 386
- amd64
- arm
- arm64
-
id: "event"
main: ./cmd/event
binary: bin/resh-event
goarch:
- 386
- amd64
- arm
- arm64
-
id: "inspect"
main: ./cmd/inspect
binary: bin/resh-inspect
goarch:
- 386
- amd64
- arm
- arm64
- -
id: "postcollect" id: "postcollect"
main: ./cmd/postcollect main: ./cmd/postcollect
@ -111,15 +84,6 @@ builds:
- amd64 - amd64
- arm - arm
- arm64 - arm64
-
id: "sanitize"
main: ./cmd/sanitize
binary: bin/resh-sanitize
goarch:
- 386
- amd64
- arm
- arm64
- -
id: "session-init" id: "session-init"
main: ./cmd/session-init main: ./cmd/session-init

@ -6,7 +6,7 @@ GOFLAGS=-ldflags "-X main.version=${VERSION} -X main.commit=${REVISION}"
build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect bin/resh-daemon\ build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect bin/resh-daemon\
bin/resh-evaluate bin/resh-sanitize bin/resh-control bin/resh-config bin/resh-inspect bin/resh-cli bin/resh-control bin/resh-config bin/resh-cli
install: build install: build
scripts/install.sh scripts/install.sh

@ -35,10 +35,6 @@ func main() {
if _, err := toml.DecodeFile(configPath, &config); err != nil { if _, err := toml.DecodeFile(configPath, &config); err != nil {
log.Fatal("Error reading config:", err) log.Fatal("Error reading config:", err)
} }
// recall command
recall := flag.Bool("recall", false, "Recall command on position --histno")
recallHistno := flag.Int("histno", 0, "Recall command on position --histno")
recallPrefix := flag.String("prefix-search", "", "Recall command based on prefix --prefix-search")
// version // version
showVersion := flag.Bool("version", false, "Show version and exit") showVersion := flag.Bool("version", false, "Show version and exit")
@ -55,11 +51,6 @@ func main() {
sessionID := flag.String("sessionId", "", "resh generated session id") sessionID := flag.String("sessionId", "", "resh generated session id")
recordID := flag.String("recordId", "", "resh generated record id") recordID := flag.String("recordId", "", "resh generated record id")
// recall metadata
recallActions := flag.String("recall-actions", "", "recall actions that took place before executing the command")
recallStrategy := flag.String("recall-strategy", "", "recall strategy used during recall actions")
recallLastCmdLine := flag.String("recall-last-cmdline", "", "last recalled cmdline")
// posix variables // posix variables
cols := flag.String("cols", "-1", "$COLUMNS") cols := flag.String("cols", "-1", "$COLUMNS")
lines := flag.String("lines", "-1", "$LINES") lines := flag.String("lines", "-1", "$LINES")
@ -127,10 +118,6 @@ func main() {
")") ")")
os.Exit(3) os.Exit(3)
} }
if *recallPrefix != "" && *recall == false {
log.Println("Option '--prefix-search' only works with '--recall' option - exiting!")
os.Exit(4)
}
realtimeBefore, err := strconv.ParseFloat(*rtb, 64) realtimeBefore, err := strconv.ParseFloat(*rtb, 64)
if err != nil { if err != nil {
@ -171,85 +158,65 @@ func main() {
// *osReleasePrettyName = "Linux" // *osReleasePrettyName = "Linux"
// } // }
if *recall { rec := records.Record{
rec := records.SlimRecord{ // posix
SessionID: *sessionID, Cols: *cols,
RecallHistno: *recallHistno, Lines: *lines,
RecallPrefix: *recallPrefix, // core
} BaseRecord: records.BaseRecord{
str, found := collect.SendRecallRequest(rec, strconv.Itoa(config.Port)) CmdLine: *cmdLine,
if found == false { ExitCode: *exitCode,
os.Exit(1) Shell: *shell,
} Uname: *uname,
fmt.Println(str) SessionID: *sessionID,
} else { RecordID: *recordID,
rec := records.Record{
// posix // posix
Cols: *cols, Home: *home,
Lines: *lines, Lang: *lang,
// core LcAll: *lcAll,
BaseRecord: records.BaseRecord{ Login: *login,
RecallHistno: *recallHistno, // Path: *path,
Pwd: *pwd,
CmdLine: *cmdLine, ShellEnv: *shellEnv,
ExitCode: *exitCode, Term: *term,
Shell: *shell,
Uname: *uname, // non-posix
SessionID: *sessionID, RealPwd: realPwd,
RecordID: *recordID, Pid: *pid,
SessionPID: *sessionPid,
// posix Host: *host,
Home: *home, Hosttype: *hosttype,
Lang: *lang, Ostype: *ostype,
LcAll: *lcAll, Machtype: *machtype,
Login: *login, Shlvl: *shlvl,
// Path: *path,
Pwd: *pwd, // before after
ShellEnv: *shellEnv, TimezoneBefore: *timezoneBefore,
Term: *term,
RealtimeBefore: realtimeBefore,
// non-posix RealtimeBeforeLocal: realtimeBeforeLocal,
RealPwd: realPwd,
Pid: *pid, RealtimeSinceSessionStart: realtimeSinceSessionStart,
SessionPID: *sessionPid, RealtimeSinceBoot: realtimeSinceBoot,
Host: *host,
Hosttype: *hosttype, GitDir: gitDir,
Ostype: *ostype, GitRealDir: gitRealDir,
Machtype: *machtype, GitOriginRemote: *gitRemote,
Shlvl: *shlvl, MachineID: collect.ReadFileContent(machineIDPath),
// before after OsReleaseID: *osReleaseID,
TimezoneBefore: *timezoneBefore, OsReleaseVersionID: *osReleaseVersionID,
OsReleaseIDLike: *osReleaseIDLike,
RealtimeBefore: realtimeBefore, OsReleaseName: *osReleaseName,
RealtimeBeforeLocal: realtimeBeforeLocal, OsReleasePrettyName: *osReleasePrettyName,
RealtimeSinceSessionStart: realtimeSinceSessionStart, PartOne: true,
RealtimeSinceBoot: realtimeSinceBoot,
ReshUUID: collect.ReadFileContent(reshUUIDPath),
GitDir: gitDir, ReshVersion: version,
GitRealDir: gitRealDir, ReshRevision: commit,
GitOriginRemote: *gitRemote, },
MachineID: collect.ReadFileContent(machineIDPath),
OsReleaseID: *osReleaseID,
OsReleaseVersionID: *osReleaseVersionID,
OsReleaseIDLike: *osReleaseIDLike,
OsReleaseName: *osReleaseName,
OsReleasePrettyName: *osReleasePrettyName,
PartOne: true,
ReshUUID: collect.ReadFileContent(reshUUIDPath),
ReshVersion: version,
ReshRevision: commit,
RecallActionsRaw: *recallActions,
RecallPrefix: *recallPrefix,
RecallStrategy: *recallStrategy,
RecallLastCmdLine: *recallLastCmdLine,
},
}
collect.SendRecord(rec, strconv.Itoa(config.Port), "/record")
} }
collect.SendRecord(rec, strconv.Itoa(config.Port), "/record")
} }

@ -20,41 +20,6 @@ type SingleResponse struct {
CmdLine string `json:"cmdline"` CmdLine string `json:"cmdline"`
} }
// SendRecallRequest to daemon
func SendRecallRequest(r records.SlimRecord, port string) (string, bool) {
recJSON, err := json.Marshal(r)
if err != nil {
log.Fatal("send err 1", err)
}
req, err := http.NewRequest("POST", "http://localhost:"+port+"/recall",
bytes.NewBuffer(recJSON))
if err != nil {
log.Fatal("send err 2", err)
}
req.Header.Set("Content-Type", "application/json")
client := httpclient.New()
resp, err := client.Do(req)
if err != nil {
log.Fatal("resh-daemon is not running - try restarting this terminal")
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal("read response error")
}
log.Println(string(body))
response := SingleResponse{}
err = json.Unmarshal(body, &response)
if err != nil {
log.Fatal("unmarshal resp error: ", err)
}
log.Println(response)
return response.CmdLine, response.Found
}
// SendRecord to daemon // SendRecord to daemon
func SendRecord(r records.Record, port, path string) { func SendRecord(r records.Record, port, path string) {
recJSON, err := json.Marshal(r) recJSON, err := json.Marshal(r)

@ -41,5 +41,3 @@
- :heavy_check_mark: Linux - :heavy_check_mark: Linux
- :white_check_mark: MacOS *(requires coreutils - `brew install coreutils`)* - :white_check_mark: MacOS *(requires coreutils - `brew install coreutils`)*
- :heavy_check_mark: Provide a tool to sanitize the recorded history

Loading…
Cancel
Save