package main import ( "fmt" "github.com/xdrm-brackets/nix-amer/internal/buildfile" "github.com/xdrm-brackets/nix-amer/internal/clifmt" "os" "time" ) func main() { start := time.Now() // Manage arguments ctx, bf, dryRun, err := GetArgs() if err != nil { fmt.Printf("%s\n", err) return } // 1. get buildfile reader bfreader, err := os.Open(bf) if err != nil { fmt.Printf("cannot open buildfile | %s\n", err) return } defer bfreader.Close() // 2. parse buildfile instructions, err := buildfile.NewReader(ctx, bfreader) if err != nil { fmt.Printf("%s%s\n", bf, err) return } clifmt.Align("build file") fmt.Printf("%s\n", clifmt.Color(32, "valid")) // stop here if dry run if dryRun { return } // 3. Execute fmt.Printf("------\n") err = instructions.Execute() if err != nil { fmt.Printf("%s\n", clifmt.Warn(err.Error())) return } fmt.Printf("------\n") clifmt.Align("finished in") fmt.Printf("%ss\n", clifmt.Color(32, fmt.Sprintf("%.2f", time.Now().Sub(start).Seconds()))) }