-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (47 loc) · 1.06 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Author : sojebsikder<sojebsikder@gmail.com>
package main
import (
"errors"
"fmt"
"log"
"os"
"github.com/sojebsikder/go-base/src/engine/mapdb"
"github.com/sojebsikder/go-base/src/engine/querydb"
)
func main() {
// app info
appName := "go-base"
version := "0.0.1"
usage := "Welcome to go-base"
description := "go-db is a simple database application"
fmt.Printf("%s %s - %s\n", appName, version, usage)
//
if len(os.Args) < 2 {
// run interactive mode
} else {
arg := os.Args[1]
if arg == "version" {
fmt.Println(appName + ": " + version)
} else if arg == "help" {
fmt.Println(description)
} else if arg == "run" {
fileName := os.Args[2]
_, err := os.Stat(fileName)
if errors.Is(err, os.ErrNotExist) {
fmt.Println("file does not exist")
} else {
content, err := os.ReadFile(fileName)
if err != nil {
log.Fatal(err)
}
querydb.Precompile(string(content))
}
} else if arg == "querydb-cli" {
querydb.Cli()
} else if arg == "mapdb-cli" {
mapdb.Cli()
} else {
fmt.Println("Invalid command")
}
}
}