diff --git a/main.go b/main.go index 4c469f2..0bf9bed 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,8 @@ import ( var ( rootDir string executeCommand string + lastPath string + lastKey string ) func main() { @@ -86,6 +88,21 @@ func ExecuteCommand(db zordfsdb.DB, commands string) error { for _, command := range strings.Split(commands, ";") { command = strings.Trim(command, " ") parts := strings.Split(command, " ") + if len(parts) > 1 { + if lastPath != "" { + if parts[1] == "_" { + parts[1] = lastPath + } else { + parts[1] = strings.Replace(parts[1], "_.", lastPath+".", 1) + } + } + + if lastKey != "" { + parts[1] = strings.Replace(parts[1], "$", lastKey, 1) + } + + lastPath = parts[1] + } switch strings.ToUpper(parts[0]) { case "KEYS": @@ -284,6 +301,7 @@ func ExecuteCommand(db zordfsdb.DB, commands string) error { } else { fmt.Printf("{%s} ADDED with ID: %s\n", parts[1], id) fmt.Println("") + lastKey = id } break