forked from project-machine/disko
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
60 lines (48 loc) · 909 Bytes
/
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
57
58
59
60
package main
import (
"fmt"
"log"
"os"
"strings"
"github.com/urfave/cli/v2"
)
var version string
func printTextTable(data [][]string) {
var lengths = make([]int, len(data[0]))
for _, line := range data {
for i, field := range line {
if len(field) > lengths[i] {
lengths[i] = len(field)
}
}
}
fmts := make([]string, len(lengths))
for i, l := range lengths {
fmts[i] = fmt.Sprintf("%%-%ds", l)
}
pfmt := strings.Join(fmts, " | ") + " |\n"
for _, line := range data {
s := make([]interface{}, len(line))
for i, v := range line {
s[i] = v
}
fmt.Printf(pfmt, s...)
}
}
func main() {
app := &cli.App{
Name: "disko-demo",
Version: version,
Usage: "Play around or test disko",
Commands: []*cli.Command{
&diskCommands,
&megaraidCommands,
&lvmCommands,
&miscCommands,
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}