mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
get variable name accepts wildcard (get api*)
This commit is contained in:
parent
eba4da1327
commit
20b6d8eef8
1 changed files with 15 additions and 11 deletions
|
@ -153,23 +153,27 @@ func (s *Session) sleepHandler(args []string, sess *Session) error {
|
||||||
|
|
||||||
func (s *Session) getHandler(args []string, sess *Session) error {
|
func (s *Session) getHandler(args []string, sess *Session) error {
|
||||||
key := args[0]
|
key := args[0]
|
||||||
if key == "*" {
|
if strings.Contains(key, "*") {
|
||||||
prev_ns := ""
|
prev_ns := ""
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
last := len(key) - 1
|
||||||
|
prefix := key[:last]
|
||||||
for _, k := range s.Env.Sorted() {
|
for _, k := range s.Env.Sorted() {
|
||||||
ns := ""
|
if strings.HasPrefix(k, prefix) {
|
||||||
toks := strings.Split(k, ".")
|
ns := ""
|
||||||
if len(toks) > 0 {
|
toks := strings.Split(k, ".")
|
||||||
ns = toks[0]
|
if len(toks) > 0 {
|
||||||
}
|
ns = toks[0]
|
||||||
|
}
|
||||||
|
|
||||||
if ns != prev_ns {
|
if ns != prev_ns {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
prev_ns = ns
|
prev_ns = ns
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" %"+strconv.Itoa(s.Env.Padding)+"s: '%s'\n", k, s.Env.Data[k])
|
fmt.Printf(" %"+strconv.Itoa(s.Env.Padding)+"s: '%s'\n", k, s.Env.Data[k])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
} else if found, value := s.Env.Get(key); found == true {
|
} else if found, value := s.Env.Get(key); found == true {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue