From 20b6d8eef8bbdd4d4d05229b37560f9667a092f9 Mon Sep 17 00:00:00 2001 From: tonjo Date: Sat, 3 Mar 2018 01:09:34 +0100 Subject: [PATCH 1/3] get variable name accepts wildcard (get api*) --- session/session_core_handlers.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index e88bacfe..241a0247 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -153,23 +153,27 @@ 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() { - ns := "" - toks := strings.Split(k, ".") - if len(toks) > 0 { - ns = toks[0] - } + if strings.HasPrefix(k, prefix) { + ns := "" + toks := strings.Split(k, ".") + if len(toks) > 0 { + ns = toks[0] + } - if ns != prev_ns { - fmt.Println() - prev_ns = ns - } + if ns != prev_ns { + fmt.Println() + 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() } else if found, value := s.Env.Get(key); found == true { From 7008ea1229ad87c95bddaec9a558d2ef7b14cfe5 Mon Sep 17 00:00:00 2001 From: tonjo Date: Sat, 3 Mar 2018 10:18:58 +0100 Subject: [PATCH 2/3] Added help for wildcard on get --- session/session_core_handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index 241a0247..9661e556 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -274,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 * as a wildcard.", s.getHandler), readline.PcItem("get", readline.PcItemDynamic(func(prefix string) []string { prefix = core.Trim(prefix[3:]) From 028555aecc93a8f41644db4af933ef2efe3d35d4 Mon Sep 17 00:00:00 2001 From: tonjo Date: Sat, 3 Mar 2018 10:21:02 +0100 Subject: [PATCH 3/3] Added help for wildcard on get --- session/session_core_handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index 9661e556..3cd5ecd5 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -274,7 +274,7 @@ func (s *Session) registerCoreHandlers() { s.addHandler(NewCommandHandler("get NAME", "^get\\s+(.+)", - "Get the value of variable NAME, use * as a wildcard.", + "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:])