(shell models.Shell, out []byte)
| 50 | } |
| 51 | |
| 52 | func toOutputFile(shell models.Shell, out []byte) (outs string) { |
| 53 | toOutputLock.Lock() |
| 54 | defer toOutputLock.Unlock() |
| 55 | |
| 56 | fileName := toOutputFilename(shell) |
| 57 | if file, err := os.OpenFile(fileName, os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644); err != nil { |
| 58 | outs = fmt.Sprintf(" > error while saving to %s: %s", fileName, err) |
| 59 | } else { |
| 60 | defer file.Close() |
| 61 | size := len(out) |
| 62 | if wrote, err := file.Write(out); err != nil { |
| 63 | outs = fmt.Sprintf(" > error while saving to %s: %s", fileName, err) |
| 64 | } else if wrote != size { |
| 65 | outs = fmt.Sprintf(" > error while saving to %s: size is %d, wrote %d", fileName, size, wrote) |
| 66 | } else { |
| 67 | outs = tui.Dim(fmt.Sprintf(" > %d bytes saved to %s", size, fileName)) |
| 68 | } |
| 69 | } |
| 70 | return |
| 71 | } |
| 72 | |
| 73 | func processOutput(out []byte, shell models.Shell) string { |
| 74 | outs := tui.Dim(" <no output>") |
no test coverage detected