-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.go
95 lines (77 loc) · 1.72 KB
/
utils.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package main
import (
"fmt"
"os"
"strconv"
"github.com/fatih/color"
)
//print fatal error and force quite app
func fatalError(err error) {
if err != nil {
color.Set(color.FgRed)
fmt.Println(err)
color.Unset()
if app != nil {
app.Stop()
}
if !debug {
os.Exit(1)
}
}
}
//print useful info and force quite app
func usefulInfo(s string) {
color.Set(color.FgHiYellow)
fmt.Println(s)
color.Unset()
}
//I2B covert int to bool, if i >0:true, else false
func I2B(i int) bool {
return i > 0
}
//F2S covert float64 to bool
func F2S(i float64) string {
return strconv.FormatFloat(i, 'f', 4, 64)
}
//S2F covert string to float64
func S2F(i string) float64 {
s, err := strconv.ParseFloat(i, 64)
if err != nil {
fatalError(err)
}
return s
}
//I2S covert int to string
func I2S(i int) string {
return strconv.Itoa(i)
}
func getHelpContent() string {
helpContent := `
C == Ctrl
##Quit##
C-c Quit
##Movement##
Left-arrow Move left
Right-arrow Move right
Down-arrow Move down
UP-arrow Move up
h Move left
l Move right
j Move down
k Move up
C-F Move down by one page
C-B Move up by one page
C-e Move to end of current column
C-h Move to head of current column
G Move to last cell of table
g Move to first cell of table
##Data Type##
C-m Change column data type to string or number
##Sort##
C-k Sort data by column(ascend)
C-l Sort data by column(descend)
##Stats##
C-y Show basic stats of current column, back to data table
`
return helpContent
}