func updateTerminalSize(term terminal.Terminal, tc terminal.Control) { width, height, err := tc.GetSize(0) if err != nil { return } term.SetSize(width, height) }
func terminalMessage(term terminal.Terminal, tc terminal.Control, color []byte, msg string, critical bool) { line := make([]byte, 0, len(msg)+16) line = append(line, ' ') line = append(line, color...) line = append(line, '*') line = append(line, tc.Escape(term).Reset...) line = append(line, []byte(fmt.Sprintf(" (%s) ", time.Now().Format(time.Kitchen)))...) if critical { line = append(line, tc.Escape(term).Red...) } line = appendTerminalEscaped(line, []byte(msg)) if critical { line = append(line, tc.Escape(term).Reset...) } line = append(line, '\n') term.Write(line) }
func critical(term terminal.Terminal, tc terminal.Control, msg string) { terminalMessage(term, tc, tc.Escape(term).Red, msg, true) }
func alert(term terminal.Terminal, tc terminal.Control, msg string) { terminalMessage(term, tc, tc.Escape(term).Red, msg, false) }
func warn(term terminal.Terminal, tc terminal.Control, msg string) { terminalMessage(term, tc, tc.Escape(term).Magenta, msg, false) }
func info(term terminal.Terminal, tc terminal.Control, msg string) { terminalMessage(term, tc, tc.Escape(term).Blue, msg, false) }