mirror of
https://github.com/bettercap/bettercap
synced 2025-07-31 12:10:10 -07:00
Merge pull request #130 from tonjo/tonjo
get variable name accepts wildcard (get api*)
This commit is contained in:
commit
a14f21da17
1 changed files with 16 additions and 12 deletions
|
@ -153,11 +153,14 @@ func (s *Session) sleepHandler(args []string, sess *Session) error {
|
|||
|
||||
func (s *Session) getHandler(args []string, sess *Session) error {
|
||||
key := args[0]
|
||||
if key == "*" {
|
||||
if strings.Contains(key, "*") {
|
||||
prev_ns := ""
|
||||
|
||||
fmt.Println()
|
||||
last := len(key) - 1
|
||||
prefix := key[:last]
|
||||
for _, k := range s.Env.Sorted() {
|
||||
if strings.HasPrefix(k, prefix) {
|
||||
ns := ""
|
||||
toks := strings.Split(k, ".")
|
||||
if len(toks) > 0 {
|
||||
|
@ -171,6 +174,7 @@ func (s *Session) getHandler(args []string, sess *Session) error {
|
|||
|
||||
fmt.Printf(" %"+strconv.Itoa(s.Env.Padding)+"s: '%s'\n", k, s.Env.Data[k])
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
} else if found, value := s.Env.Get(key); found == true {
|
||||
fmt.Println()
|
||||
|
@ -270,7 +274,7 @@ func (s *Session) registerCoreHandlers() {
|
|||
|
||||
s.addHandler(NewCommandHandler("get NAME",
|
||||
"^get\\s+(.+)",
|
||||
"Get the value of variable NAME, use * for all.",
|
||||
"Get the value of variable NAME, use * alone for all, or NAME* as a wildcard.",
|
||||
s.getHandler),
|
||||
readline.PcItem("get", readline.PcItemDynamic(func(prefix string) []string {
|
||||
prefix = core.Trim(prefix[3:])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue