added INFO command
This commit is contained in:
parent
b64507ff31
commit
098b809310
1 changed files with 31 additions and 2 deletions
33
main.go
33
main.go
|
@ -44,7 +44,6 @@ func main() {
|
||||||
text, _ := reader.ReadString('\n')
|
text, _ := reader.ReadString('\n')
|
||||||
// convert CRLF to LF
|
// convert CRLF to LF
|
||||||
text = strings.Replace(text, "\n", "", -1)
|
text = strings.Replace(text, "\n", "", -1)
|
||||||
fmt.Println(text)
|
|
||||||
|
|
||||||
if strings.Compare("QUIT", strings.ToUpper(text)) == 0 || strings.Compare("\\Q", strings.ToUpper(text)) == 0 {
|
if strings.Compare("QUIT", strings.ToUpper(text)) == 0 || strings.Compare("\\Q", strings.ToUpper(text)) == 0 {
|
||||||
fmt.Println("\nBye o/")
|
fmt.Println("\nBye o/")
|
||||||
|
@ -64,6 +63,7 @@ DEL [path] - remove property/object/list (no confirmation)
|
||||||
SAVE [path] [value] - set value to property
|
SAVE [path] [value] - set value to property
|
||||||
CREATE [path] - create list/object in path (parent path should exist)
|
CREATE [path] - create list/object in path (parent path should exist)
|
||||||
ADD [path] - add abcex indexed object to list. Will return index
|
ADD [path] - add abcex indexed object to list. Will return index
|
||||||
|
INFO [path] - get all info about property/object/list
|
||||||
HELP - will print this help
|
HELP - will print this help
|
||||||
QUIT - exit the shell
|
QUIT - exit the shell
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ Last used path can be accessed by _
|
||||||
Last returned index (after ADD command) can be accessed by $
|
Last returned index (after ADD command) can be accessed by $
|
||||||
|
|
||||||
Short commands can be as:
|
Short commands can be as:
|
||||||
KEYS(\K), GET(\G), INC(\I), DEC(\D), NOW(\N), DEL(\R), SAVE(\S), CREATE(\C), ADD(\A), HELP(\H), QUIT(\Q)
|
KEYS(\K), GET(\G), INC(\I), DEC(\D), NOW(\N), DEL(\R), SAVE(\S), CREATE(\C), ADD(\A), INFO(\?), HELP(\H), QUIT(\Q)
|
||||||
`)
|
`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,35 @@ func ExecuteCommand(db zordfsdb.DB, commands string) error {
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case "INFO":
|
||||||
|
case "\\?":
|
||||||
|
if len(parts) == 1 || len(parts[1]) == 0 {
|
||||||
|
return fmt.Errorf("err format: INFO [path]\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
node, ok := db.GetNode(parts[1])
|
||||||
|
if !ok {
|
||||||
|
fmt.Println("No path found.")
|
||||||
|
fmt.Println("")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("{%s} INFO\n-----------------\n", parts[1])
|
||||||
|
ntype := "property"
|
||||||
|
if node.List {
|
||||||
|
ntype = "list"
|
||||||
|
} else if node.Object {
|
||||||
|
ntype = "object"
|
||||||
|
}
|
||||||
|
fmt.Println("type:", ntype)
|
||||||
|
if ntype == "property" {
|
||||||
|
fmt.Println("value:", node.Value)
|
||||||
|
} else {
|
||||||
|
fmt.Println("keys:", db.Keys(parts[1]))
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("")
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
case "GET":
|
case "GET":
|
||||||
case "\\G":
|
case "\\G":
|
||||||
if len(parts) == 1 || len(parts[1]) == 0 {
|
if len(parts) == 1 || len(parts[1]) == 0 {
|
||||||
|
|
Loading…
Reference in a new issue