github.com/andrewrech/lazygit@v0.8.1/main.go (about)

     1  package main
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"log"
     7  	"os"
     8  	"path/filepath"
     9  	"runtime"
    10  
    11  	"github.com/go-errors/errors"
    12  	"github.com/jesseduffield/lazygit/pkg/app"
    13  	"github.com/jesseduffield/lazygit/pkg/config"
    14  )
    15  
    16  var (
    17  	commit      string
    18  	version     = "unversioned"
    19  	date        string
    20  	buildSource = "unknown"
    21  
    22  	configFlag    = flag.Bool("config", false, "Print the current default config")
    23  	debuggingFlag = flag.Bool("debug", false, "a boolean")
    24  	versionFlag   = flag.Bool("v", false, "Print the current version")
    25  )
    26  
    27  func projectPath(path string) string {
    28  	gopath := os.Getenv("GOPATH")
    29  	return filepath.FromSlash(gopath + "/src/github.com/jesseduffield/lazygit/" + path)
    30  }
    31  
    32  func main() {
    33  	flag.Parse()
    34  	if *versionFlag {
    35  		fmt.Printf("commit=%s, build date=%s, build source=%s, version=%s, os=%s, arch=%s\n", commit, date, buildSource, version, runtime.GOOS, runtime.GOARCH)
    36  		os.Exit(0)
    37  	}
    38  
    39  	if *configFlag {
    40  		fmt.Printf("%s\n", config.GetDefaultConfig())
    41  		os.Exit(0)
    42  	}
    43  	appConfig, err := config.NewAppConfig("lazygit", version, commit, date, buildSource, *debuggingFlag)
    44  	if err != nil {
    45  		log.Fatal(err.Error())
    46  	}
    47  
    48  	app, err := app.NewApp(appConfig)
    49  
    50  	if err == nil {
    51  		err = app.Run()
    52  	}
    53  
    54  	if err != nil {
    55  		newErr := errors.Wrap(err, 0)
    56  		stackTrace := newErr.ErrorStack()
    57  		app.Log.Error(stackTrace)
    58  
    59  		log.Fatal(fmt.Sprintf("%s\n\n%s", app.Tr.SLocalize("ErrorOccurred"), stackTrace))
    60  	}
    61  }