-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (35 loc) · 897 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
package main
import (
"fmt"
"os"
"path"
"github.com/joho/godotenv"
"github.com/spf13/afero"
)
func main() {
// look for the current working directory
cwd, err := os.Getwd()
if err != nil {
fmt.Printf("Sorry, there was a problem: %s.\n", err.Error())
os.Exit(1)
}
// load the current configuration from the filesystem
config, err := LoadConfig(afero.NewOsFs(), cwd)
if err != nil {
fmt.Printf("Sorry, there was a problem: %s.\n", err.Error())
os.Exit(1)
}
// load any environment files that are in the same directory as the taskfile
_ = godotenv.Load(path.Join(config.rootDir, ".env"))
// convert the configuration into a command we can execute
cmd, err := config.Cmd()
if err != nil {
fmt.Printf("Sorry, there was a problem: %s.\n", err.Error())
os.Exit(1)
}
// execute the command
if err := cmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}