From b7f6bcb3caa45ecb516670704513110a7d2f6a74 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sun, 26 Aug 2018 10:42:25 +0200 Subject: [PATCH] add config flag --- main.go | 5 +++++ pkg/config/app_config.go | 37 ++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index e8c092da2..758a0ee50 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ var ( version = "unversioned" date string + 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") ) @@ -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) os.Exit(0) } + if *configFlag { + fmt.Printf("%s\n", config.GetDefaultConfig()) + os.Exit(0) + } appConfig, err := config.NewAppConfig("lazygit", version, commit, date, debuggingFlag) if err != nil { panic(err) diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index aa56365e3..d49ddd4d5 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -101,7 +101,7 @@ func LoadUserConfig() (*viper.Viper, error) { // LoadDefaultConfig loads in the defaults defined in this file func LoadDefaultConfig(v *viper.Viper) error { - defaults := getDefaultConfig() + defaults := GetDefaultConfig() return v.ReadConfig(bytes.NewBuffer(defaults)) } @@ -139,24 +139,23 @@ func (c *AppConfig) InsertToUserConfig(key, value string) error { return v.WriteConfig() } -func getDefaultConfig() []byte { - return []byte(` - gui: - ## stuff relating to the UI - scrollHeight: 2 - theme: - activeBorderColor: - - white - - bold - inactiveBorderColor: - - white - optionsTextColor: - - blue - git: - # stuff relating to git - os: - # stuff relating to the OS - +func GetDefaultConfig() []byte { + return []byte( +`gui: + # stuff relating to the UI + scrollHeight: 2 + theme: + activeBorderColor: + - white + - bold + inactiveBorderColor: + - white + optionsTextColor: + - blue +git: + # stuff relating to git +os: + # stuff relating to the OS `) }