webcmd: MaxHistoryLines

This commit is contained in:
mappu 2017-03-25 15:55:48 +13:00
parent d0fed6e4cf
commit 7dde122d9b
3 changed files with 9 additions and 3 deletions

View File

@ -85,6 +85,9 @@ func (this *App) LaunchTask(params []string) (taskRef string, err error) {
task := this.tasks[ref]
task.output = append(task.output, OutputLine{isError: isError, text: text})
if len(task.output) > 2*this.cfg.MaxHistoryLines {
task.output = task.output[this.cfg.MaxHistoryLines:]
}
this.tasks[ref] = task
}

View File

@ -3,6 +3,8 @@
"ListenAddress": ":8192",
"MaxHistoryLines": 100,
"Commands": [
{

View File

@ -27,7 +27,8 @@ type CommandConfig struct {
}
type AppConfig struct {
ListenAddress string
AppTitle string
Commands []CommandConfig
ListenAddress string
AppTitle string
MaxHistoryLines int // default zero: unlimited history for each command
Commands []CommandConfig
}