new: ble, can, hid and wifi modules will now set a custom prompt (closes #1117)

This commit is contained in:
Simone Margaritelli 2024-08-17 12:10:38 +02:00
commit 6282fe3451
7 changed files with 80 additions and 36 deletions

View file

@ -144,11 +144,15 @@ func (mod *CANModule) onFrame(frame can.Frame) {
mod.Session.Events.Add("can.message", msg)
}
const canPrompt = "{br}{fw}{env.can.device} {fb}{reset} {bold}» {reset}"
func (mod *CANModule) Start() error {
if err := mod.Configure(); err != nil {
return err
}
mod.SetPrompt(canPrompt)
return mod.SetRunning(true, func() {
mod.Info("started on %s ...", mod.deviceName)
@ -160,6 +164,8 @@ func (mod *CANModule) Start() error {
}
func (mod *CANModule) Stop() error {
mod.SetPrompt(session.DefaultPrompt)
return mod.SetRunning(false, func() {
if mod.conn != nil {
mod.recv.Close()