mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
new: ble, can, hid and wifi modules will now set a custom prompt (closes #1117)
This commit is contained in:
parent
d9a91d393e
commit
6282fe3451
7 changed files with 80 additions and 36 deletions
|
@ -458,10 +458,18 @@ func (s *Session) Run(line string) error {
|
|||
}
|
||||
|
||||
// is it a module command?
|
||||
for _, m := range s.Modules {
|
||||
for _, h := range m.Handlers() {
|
||||
if parsed, args := h.Parse(line); parsed {
|
||||
return h.Exec(args)
|
||||
for _, mod := range s.Modules {
|
||||
for _, modHandler := range mod.Handlers() {
|
||||
if parsed, args := modHandler.Parse(line); parsed {
|
||||
if err := modHandler.Exec(args); err != nil {
|
||||
return err
|
||||
} else if prompt := mod.Prompt(); prompt != "" {
|
||||
// if the module handler has been executed successfully and
|
||||
// the module overrides the prompt, set it
|
||||
s.Env.Set(PromptVariable, prompt)
|
||||
s.Refresh()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -478,5 +486,5 @@ func (s *Session) Run(line string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("unknown or invalid syntax \"%s%s%s\", type %shelp%s for the help menu.", tui.BOLD, line, tui.RESET, tui.BOLD, tui.RESET)
|
||||
return fmt.Errorf("unknown or invalid syntax \"%s%s%s\", type %shelp%s for the help menu", tui.BOLD, line, tui.RESET, tui.BOLD, tui.RESET)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue