summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorAndrei Miulescu <lusu777@gmail.com>2018-08-12 19:31:27 +1000
committerAndrei Miulescu <lusu777@gmail.com>2018-08-12 19:31:27 +1000
commitdcd461d29f21a9626d5298a03283b6d8b46312c3 (patch)
tree42f43f27eb7403c60cc05805fc627debff76417b /main.go
parent98c22a36fdaf8806f8fafe8f1e23e53f8e97658d (diff)
Restrucure project in a way where it is more modular
Diffstat (limited to 'main.go')
-rw-r--r--main.go31
1 files changed, 18 insertions, 13 deletions
diff --git a/main.go b/main.go
index aec4051bf..aa157c108 100644
--- a/main.go
+++ b/main.go
@@ -14,6 +14,8 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/jesseduffield/gocui"
+ "github.com/jesseduffield/lazygit/pkg/app"
+ "github.com/jesseduffield/lazygit/pkg/config"
git "gopkg.in/src-d/go-git.v4"
)
@@ -24,8 +26,8 @@ var (
commit string
version = "unversioned"
+ date string
- date string
debuggingFlag = flag.Bool("debug", false, "a boolean")
versionFlag = flag.Bool("v", false, "Print the current version")
@@ -77,15 +79,6 @@ func localLog(path string, objects ...interface{}) {
}
}
-func navigateToRepoRootDirectory() {
- _, err := os.Stat(".git")
- for os.IsNotExist(err) {
- devLog("going up a directory to find the root")
- os.Chdir("..")
- _, err = os.Stat(".git")
- }
-}
-
// when building the binary, `version` is set as a compile-time variable, along
// with `date` and `commit`. If this program has been opened directly via go,
// we will populate the `version` with VERSION in the lazygit root directory
@@ -112,7 +105,6 @@ func setupWorktree() {
}
func main() {
- devLog("\n\n\n\n\n\n\n\n\n\n")
flag.Parse()
if version == "unversioned" {
version = fallbackVersion()
@@ -121,9 +113,22 @@ func main() {
fmt.Printf("commit=%s, build date=%s, version=%s", commit, date, version)
os.Exit(0)
}
- verifyInGitRepo()
- navigateToRepoRootDirectory()
+ appConfig := &config.AppConfig{
+ Name: "lazygit",
+ Version: version,
+ Commit: commit,
+ BuildDate: date,
+ Debug: *debuggingFlag,
+ }
+ app, err := app.NewApp(appConfig)
+ app.Log.Info(err)
+
+ app.GitCommand.SetupGit()
+ // TODO remove this once r, w not used
setupWorktree()
+
+ app.Gui.Run()
+
for {
if err := run(); err != nil {
if err == gocui.ErrQuit {