-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (39 loc) · 936 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
package main
import (
"log"
"os"
"os/exec"
"github.com/joho/godotenv"
"github.com/urfave/cli"
)
func main() {
// Load environment variables
if err := godotenv.Load(); err != nil {
log.Fatal("Error loading .env file")
}
// Create a new CLI app
app := cli.NewApp()
app.Name = "Cli-Tools"
app.Usage = "A simple library of cli tools built and used by topic to make the devs life easier!"
app.Version = "1.0.0"
// Define commands
app.Commands = []cli.Command{
{
Name: "Convert Struct",
Aliases: []string{"conv"},
Usage: "Convert bot structure present in the old db for topic for the new db",
Action: func(c *cli.Context) error {
folderPath := "./mongo/botstructconv"
cmd := exec.Command("go", "run", folderPath+".go")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
},
},
}
// Run the CLI app
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}