(pid uint, command string)
| 89 | } |
| 90 | |
| 91 | func apiPostexecMain(pid uint, command string) { |
| 92 | app := NewApplication() |
| 93 | |
| 94 | dir, err := os.Getwd() |
| 95 | if err != nil { |
| 96 | fatal(err) |
| 97 | } |
| 98 | |
| 99 | req := server.ParseCommandLineRequest{ |
| 100 | Pid: int(pid), |
| 101 | CommandLine: command, |
| 102 | Dir: dir, |
| 103 | Env: os.Environ(), |
| 104 | } |
| 105 | rsp := server.ParseCommandLineResponse{} |
| 106 | |
| 107 | err = app.Client().Request(&req, &rsp) |
| 108 | if err != nil { |
| 109 | if server.GetErrorCode(err) == server.BinaryNotFound { |
| 110 | return |
| 111 | } |
| 112 | fatal(err) |
| 113 | } |
| 114 | |
| 115 | if len(rsp.Args) == 0 || !rsp.IsHelpCommand || rsp.PolicyMode == datastore.PolicyIgnore { |
| 116 | return |
| 117 | } |
| 118 | |
| 119 | if rsp.PolicyMode == datastore.PolicyTrust { |
| 120 | // send update request |
| 121 | req := server.AddHelpPageRequest{ |
| 122 | Command: datastore.Command{ |
| 123 | Args: rsp.Args, |
| 124 | Env: append(os.Environ(), rsp.Env...), |
| 125 | Dir: dir, |
| 126 | }, |
| 127 | } |
| 128 | rsp := server.AddHelpPageResponse{} |
| 129 | |
| 130 | err = app.Client().Request(&req, &rsp) |
| 131 | verifyFatal(err) |
| 132 | err = summarizeLearning(&rsp) |
| 133 | verifyFatal(err) |
| 134 | return |
| 135 | } |
| 136 | |
| 137 | ui := NewUI() |
| 138 | |
| 139 | // https://en.wikipedia.org/wiki/Box_Drawing_(Unicode_block) |
| 140 | shortOptions := fmt.Sprintf( |
| 141 | "┌──> %v\n└─── cod: learn this command? [yn?] > ", |
| 142 | strings.Join(rsp.Args, " "), |
| 143 | ) |
| 144 | |
| 145 | fullOptions := "\n" |
| 146 | fullOptions += " y => Yes and enable autoupdates for this commands\n" |
| 147 | fullOptions += " n => Not now\n" |
| 148 | fullOptions += " ? => show this help\n" |
no test coverage detected