| 1 | package sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/ |
| 2 | |
| 3 | import ( |
| 4 | "regexpscip-go gomod github.com/golang/go/src go1.16 regexp/" |
| 5 | "syncscip-go gomod github.com/golang/go/src go1.16 sync/" |
| 6 | |
| 7 | "github.com/bettercap/readlinescip-go gomod github.com/bettercap/readline 655e48bcb7bf `github.com/bettercap/readline`/" |
| 8 | ) |
| 9 | |
| 10 | type CommandHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler# struct { |
| 11 | *syncscip-go gomod github.com/golang/go/src go1.16 sync/.Mutexscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Mutex. |
| 12 | Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Name. string |
| 13 | Descriptionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Description. string |
| 14 | Completerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Completer. *readlinescip-go gomod github.com/bettercap/readline 655e48bcb7bf `github.com/bettercap/readline`/.PrefixCompleterscip-go gomod github.com/bettercap/readline 655e48bcb7bf `github.com/bettercap/readline`/PrefixCompleter# |
| 15 | Parserscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Parser. *regexpscip-go gomod github.com/golang/go/src go1.16 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.16 regexp/Regexp# |
| 16 | execscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#exec. func(args []string, s *Sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#) error |
| 17 | } |
| 18 | |
| 19 | func NewCommandHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/NewCommandHandler().(name string, expr string, desc string, exec func(args []string, s *Sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#) error) CommandHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler# { |
| 20 | return CommandHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#{ |
| 21 | Mutexscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Mutex.: &syncscip-go gomod github.com/golang/go/src go1.16 sync/.Mutexscip-go gomod github.com/golang/go/src go1.16 sync/Mutex#{}, |
| 22 | Namescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Name.: name, |
| 23 | Descriptionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Description.: desc, |
| 24 | Completerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Completer.: nil, |
| 25 | Parserscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Parser.: regexpscip-go gomod github.com/golang/go/src go1.16 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.16 regexp/MustCompile().(expr), |
| 26 | execscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#exec.: exec, |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | func (h *CommandHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#) Parsescip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Parse().(line string) (bool, []string) { |
| 31 | result := h.Parserscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Parser..FindStringSubmatchscip-go gomod github.com/golang/go/src go1.16 regexp/Regexp#FindStringSubmatch().(line) |
| 32 | if len(result) == h.Parserscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Parser..NumSubexpscip-go gomod github.com/golang/go/src go1.16 regexp/Regexp#NumSubexp().()+1 { |
| 33 | return true, result[1:] |
| 34 | } else { |
| 35 | return false, nil |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func (h *CommandHandlerscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#) Execscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#Exec().(args []string, s *Sessionscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/Session#) error { |
| 40 | h.Lockscip-go gomod github.com/golang/go/src go1.16 sync/Mutex#Lock().() |
| 41 | defer h.Unlockscip-go gomod github.com/golang/go/src go1.16 sync/Mutex#Unlock().() |
| 42 | return h.execscip-go gomod github.com/bettercap/bettercap . `github.com/bettercap/bettercap/session`/CommandHandler#exec.(args, s) |
| 43 | } |