mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-27 12:32:37 +02:00
Main: Added directory argument
* Added a positional argument that allows the user to change the dir Signed-off-by: Glenn Vriesman <glenn.vriesman@gmail.com>
This commit is contained in:
parent
379dcf0972
commit
431f1aa766
1
go.mod
1
go.mod
@ -22,6 +22,7 @@ require (
|
|||||||
github.com/hashicorp/go-safetemp v0.0.0-20180326211150-b1a1dbde6fdc // indirect
|
github.com/hashicorp/go-safetemp v0.0.0-20180326211150-b1a1dbde6fdc // indirect
|
||||||
github.com/hashicorp/go-version v1.0.0 // indirect
|
github.com/hashicorp/go-version v1.0.0 // indirect
|
||||||
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
|
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
|
||||||
|
github.com/integrii/flaggy v1.2.2
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||||
github.com/jesseduffield/go-getter v0.0.0-20180822080847-906e15686e63
|
github.com/jesseduffield/go-getter v0.0.0-20180822080847-906e15686e63
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20190908012510-092b2290ee54
|
github.com/jesseduffield/gocui v0.3.1-0.20190908012510-092b2290ee54
|
||||||
|
2
go.sum
2
go.sum
@ -48,6 +48,8 @@ github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce h1:xdsDDbiBDQTKASoGE
|
|||||||
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
|
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/integrii/flaggy v1.2.2 h1:SzL5kyEaW+Cb3RLxGG1ch9FFDLQPB6QuMdYoNu5JIo0=
|
||||||
|
github.com/integrii/flaggy v1.2.2/go.mod h1:tnTxHeTJbah0gQ6/K0RW0J7fMUBk9MCF5blhm43LNpI=
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||||
github.com/jesseduffield/go-getter v0.0.0-20180822080847-906e15686e63 h1:tbm85YuPi3d1LFAUr6yZyzZ4vR96ygV98rezZZ+ywbg=
|
github.com/jesseduffield/go-getter v0.0.0-20180822080847-906e15686e63 h1:tbm85YuPi3d1LFAUr6yZyzZ4vR96ygV98rezZZ+ywbg=
|
||||||
|
36
main.go
36
main.go
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@ -9,6 +8,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
|
"github.com/integrii/flaggy"
|
||||||
"github.com/jesseduffield/lazygit/pkg/app"
|
"github.com/jesseduffield/lazygit/pkg/app"
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
)
|
)
|
||||||
@ -18,10 +18,6 @@ var (
|
|||||||
version = "unversioned"
|
version = "unversioned"
|
||||||
date string
|
date string
|
||||||
buildSource = "unknown"
|
buildSource = "unknown"
|
||||||
|
|
||||||
configFlag = flag.Bool("config", false, "Print the current default config")
|
|
||||||
debuggingFlag = flag.Bool("debug", false, "a boolean")
|
|
||||||
versionFlag = flag.Bool("v", false, "Print the current version")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func projectPath(path string) string {
|
func projectPath(path string) string {
|
||||||
@ -30,17 +26,39 @@ func projectPath(path string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flaggy.DefaultParser.ShowVersionWithVersionFlag = false
|
||||||
if *versionFlag {
|
|
||||||
|
repoPath := "."
|
||||||
|
flaggy.AddPositionalValue(&repoPath, "path", 1, false, "Path of git repo")
|
||||||
|
|
||||||
|
versionFlag := false
|
||||||
|
flaggy.Bool(&versionFlag, "v", "version", "Print the current version")
|
||||||
|
|
||||||
|
debuggingFlag := false
|
||||||
|
flaggy.Bool(&debuggingFlag, "d", "debug", "Run in debug mode with logging")
|
||||||
|
|
||||||
|
configFlag := false
|
||||||
|
flaggy.Bool(&configFlag, "c", "config", "Print the current default config")
|
||||||
|
|
||||||
|
flaggy.Parse()
|
||||||
|
|
||||||
|
if versionFlag {
|
||||||
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)
|
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)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *configFlag {
|
if configFlag {
|
||||||
fmt.Printf("%s\n", config.GetDefaultConfig())
|
fmt.Printf("%s\n", config.GetDefaultConfig())
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
appConfig, err := config.NewAppConfig("lazygit", version, commit, date, buildSource, *debuggingFlag)
|
|
||||||
|
if repoPath != "." {
|
||||||
|
if err := os.Chdir(repoPath); err != nil {
|
||||||
|
log.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
appConfig, err := config.NewAppConfig("lazygit", version, commit, date, buildSource, debuggingFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user