@@ -52,6 +52,7 @@ const (
5252)
5353
5454type model struct {
55+ kpHist bool
5556 history viewport.Model
5657 msgs []c.SMsg
5758 showTim showTim
@@ -67,15 +68,17 @@ type model struct {
6768}
6869
6970type args struct {
70- Address string `arg:"positional" default:"gochat.8bit.lol" help:"address to connect to, without ws://" placeholder:"HOST[:PORT]"`
71- Timestamps showTim `arg:"-t" default:"off" help:"display timestamps of messages, ctrl+t to cycle after startup [off, short, full]" placeholder:"CHOICE"`
72- Nick * string `arg:"-n" help:"attempt to automatically set nick after connecting"`
73- Password * string `arg:"-p" help:"password, if required"`
71+ Address string `arg:"positional" default:"gochat.8bit.lol" help:"address to connect to, without ws://" placeholder:"HOST[:PORT]"`
72+ KeepHistory bool `arg:"-k" help:"append chat history when changing rooms, instead of clearing"`
73+ Timestamps showTim `arg:"-t" default:"off" help:"display timestamps of messages, ctrl+t to cycle after startup [off, short, full]" placeholder:"CHOICE"`
74+ Nick * string `arg:"-n" help:"attempt to automatically set nick after connecting"`
75+ Password * string `arg:"-p" help:"password, if required"`
7476}
7577
7678func (a * args ) Version () string {
77- return "v0.2.1 "
79+ return "v0.2.3 "
7880}
81+
7982func (a * args ) Description () string {
8083 return "Go, chat!\n A basic irc-style chat client, written in Go using bubbletea and websockets"
8184}
@@ -180,6 +183,7 @@ func initModel(ctx context.Context, conn *ws.Conn, a args, tz time.Location) mod
180183 msgs : messages ,
181184 showTim : a .Timestamps ,
182185 tz : tz ,
186+ kpHist : a .KeepHistory ,
183187 history : vp ,
184188 idStyle : lipgloss .NewStyle ().Width (60 ),
185189 pStyle : lipgloss .NewStyle ().Bold (true ),
@@ -230,6 +234,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
230234 } else if text == "ls" {
231235 m .sendCh <- c.CMsg {Typ : c .Ls , Msg : "" }
232236 } else if text , ok := strings .CutPrefix (text , "cd " ); ok {
237+ if ! m .kpHist {
238+ m .msgs = []c.SMsg {}
239+ }
233240 m .sendCh <- c.CMsg {Typ : c .Cd , Msg : text }
234241 } else if text == "who" {
235242 m .sendCh <- c.CMsg {Typ : c .Who , Msg : "" }
0 commit comments