mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
add config flag
This commit is contained in:
parent
93ab892bdd
commit
b7f6bcb3ca
2 changed files with 23 additions and 19 deletions
5
main.go
5
main.go
|
@ -16,6 +16,7 @@ var (
|
||||||
version = "unversioned"
|
version = "unversioned"
|
||||||
date string
|
date string
|
||||||
|
|
||||||
|
configFlag = flag.Bool("config", false, "Print the current default config")
|
||||||
debuggingFlag = flag.Bool("debug", false, "a boolean")
|
debuggingFlag = flag.Bool("debug", false, "a boolean")
|
||||||
versionFlag = flag.Bool("v", false, "Print the current version")
|
versionFlag = flag.Bool("v", false, "Print the current version")
|
||||||
)
|
)
|
||||||
|
@ -31,6 +32,10 @@ func main() {
|
||||||
fmt.Printf("commit=%s, build date=%s, version=%s, os=%s, arch=%s\n", commit, date, version, runtime.GOOS, runtime.GOARCH)
|
fmt.Printf("commit=%s, build date=%s, version=%s, os=%s, arch=%s\n", commit, date, version, runtime.GOOS, runtime.GOARCH)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
if *configFlag {
|
||||||
|
fmt.Printf("%s\n", config.GetDefaultConfig())
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
appConfig, err := config.NewAppConfig("lazygit", version, commit, date, debuggingFlag)
|
appConfig, err := config.NewAppConfig("lazygit", version, commit, date, debuggingFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -101,7 +101,7 @@ func LoadUserConfig() (*viper.Viper, error) {
|
||||||
|
|
||||||
// LoadDefaultConfig loads in the defaults defined in this file
|
// LoadDefaultConfig loads in the defaults defined in this file
|
||||||
func LoadDefaultConfig(v *viper.Viper) error {
|
func LoadDefaultConfig(v *viper.Viper) error {
|
||||||
defaults := getDefaultConfig()
|
defaults := GetDefaultConfig()
|
||||||
return v.ReadConfig(bytes.NewBuffer(defaults))
|
return v.ReadConfig(bytes.NewBuffer(defaults))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,24 +139,23 @@ func (c *AppConfig) InsertToUserConfig(key, value string) error {
|
||||||
return v.WriteConfig()
|
return v.WriteConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultConfig() []byte {
|
func GetDefaultConfig() []byte {
|
||||||
return []byte(`
|
return []byte(
|
||||||
gui:
|
`gui:
|
||||||
## stuff relating to the UI
|
# stuff relating to the UI
|
||||||
scrollHeight: 2
|
scrollHeight: 2
|
||||||
theme:
|
theme:
|
||||||
activeBorderColor:
|
activeBorderColor:
|
||||||
- white
|
- white
|
||||||
- bold
|
- bold
|
||||||
inactiveBorderColor:
|
inactiveBorderColor:
|
||||||
- white
|
- white
|
||||||
optionsTextColor:
|
optionsTextColor:
|
||||||
- blue
|
- blue
|
||||||
git:
|
git:
|
||||||
# stuff relating to git
|
# stuff relating to git
|
||||||
os:
|
os:
|
||||||
# stuff relating to the OS
|
# stuff relating to the OS
|
||||||
|
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue