support _ and $
This commit is contained in:
parent
7f2f9d47ed
commit
768db4e04b
1 changed files with 18 additions and 0 deletions
18
main.go
18
main.go
|
@ -13,6 +13,8 @@ import (
|
||||||
var (
|
var (
|
||||||
rootDir string
|
rootDir string
|
||||||
executeCommand string
|
executeCommand string
|
||||||
|
lastPath string
|
||||||
|
lastKey string
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -86,6 +88,21 @@ func ExecuteCommand(db zordfsdb.DB, commands string) error {
|
||||||
for _, command := range strings.Split(commands, ";") {
|
for _, command := range strings.Split(commands, ";") {
|
||||||
command = strings.Trim(command, " ")
|
command = strings.Trim(command, " ")
|
||||||
parts := strings.Split(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]) {
|
switch strings.ToUpper(parts[0]) {
|
||||||
case "KEYS":
|
case "KEYS":
|
||||||
|
@ -284,6 +301,7 @@ func ExecuteCommand(db zordfsdb.DB, commands string) error {
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("{%s} ADDED with ID: %s\n", parts[1], id)
|
fmt.Printf("{%s} ADDED with ID: %s\n", parts[1], id)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
|
lastKey = id
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue