-
Notifications
You must be signed in to change notification settings - Fork 7
/
cmd.go
68 lines (57 loc) · 1.11 KB
/
cmd.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
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"strconv"
"strings"
)
func exportCMD(words []string) {
if ok := validateCommandParamters(2, len(words)-1); !ok {
return
}
err := createFileFromTable(words[1], words[2])
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println("file exported")
}
func showCMD(words []string) {
if ok := validateCommandParamters(2, len(words)-1); !ok {
return
}
n, _ := strconv.Atoi(words[2])
columns, rows, err := tableSelect(words[1], n)
if err != nil {
fmt.Println(err.Error())
return
}
tableRender(columns, rows)
}
func listCMD() {
err := list()
if err != nil {
fmt.Println(err.Error())
}
}
func loadCMD(words []string) {
tablename := words[0]
err := loadFiles(tablename, words[3])
if err != nil {
fmt.Println(err.Error())
return
}
}
func selectCMD(words []string) {
err := createTableFromQuery(words[0], strings.Join(words[2:], " "))
if err != nil {
fmt.Println(err.Error())
return
}
}
func selectAppendCMD(words []string) {
err := appendToTableFromQuery(words[0], strings.Join(words[2:], " "))
if err != nil {
fmt.Println(err.Error())
return
}
}