-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (29 loc) · 826 Bytes
/
main.go
File metadata and controls
34 lines (29 loc) · 826 Bytes
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
package main
import (
"flag"
"fmt"
"github.com/LissaGreense/GO4SQL/engine"
"github.com/LissaGreense/GO4SQL/modes"
"log"
)
func main() {
filePath := flag.String("file", "", "Provide a path to the .sql file")
streamMode := flag.Bool("stream", false, "Use to redirect stdin to stdout")
socketMode := flag.Bool("socket", false, "Use to start socket server")
port := flag.Int("port", 1433, "States on which port socket server will listen")
flag.Parse()
engineSQL := engine.New()
var err error
if len(*filePath) > 0 {
err = modes.HandleFileMode(*filePath, engineSQL)
} else if *streamMode {
err = modes.HandleStreamMode(engineSQL)
} else if *socketMode {
modes.HandleSocketMode(*port, engineSQL)
} else {
err = fmt.Errorf("no mode has been providing, exiting")
}
if err != nil {
log.Fatal(err)
}
}