Skip to content

Commit

Permalink
ref: pretty print startup information
Browse files Browse the repository at this point in the history
  • Loading branch information
leukipp committed Aug 1, 2024
1 parent 6ee7f8c commit 6333cd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
22 changes: 14 additions & 8 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,26 @@ func ConfigFolderPath(name string) string {
}

func readConfig(configFilePath string) {
fmt.Printf("LOAD %s [%s]\n", configFilePath, Build.Summary)

// Decode contents into struct
// Print build infos
fmt.Printf("BUILD: \n name: %s\n version: v%s-%s\n date: %s\n\n", Build.Name, Build.Version, Build.Commit, Build.Date)

// Print file infos
fmt.Printf("FILES: \n log: %s\n lock: %s\n cache: %s\n config: %s\n\n", Args.Log, Args.Lock, Args.Cache, configFilePath)

// Decode config file into struct
toml.DecodeFile(configFilePath, &Config)

// Print shortcuts
// Print shortcut infos
keys, _ := json.MarshalIndent(Config.Keys, "", " ")
Corners, _ := json.MarshalIndent(Config.Corners, "", " ")
Systray, _ := json.MarshalIndent(Config.Systray, "", " ")
corners, _ := json.MarshalIndent(Config.Corners, "", " ")
systray, _ := json.MarshalIndent(Config.Systray, "", " ")

fmt.Printf("KEYS %s\n", string(keys))
fmt.Printf("CORNERS %s\n", string(Corners))
fmt.Printf("SYSTRAY %s\n", string(Systray))
fmt.Printf("KEYS: %s\n", RemoveChars(string(keys), []string{"{", "}", "\"", ","}))
fmt.Printf("CORNERS: %s\n", RemoveChars(string(corners), []string{"{", "}", "\"", ","}))
fmt.Printf("SYSTRAY: %s\n", RemoveChars(string(systray), []string{"{", "}", "\"", ","}))

// Log startup infos
log.Info("Starting [", Build.Summary, "]")
}

Expand Down
7 changes: 7 additions & 0 deletions common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ func TruncateString(s string, max int) string {
return s[:max]
}

func RemoveChars(s string, chars []string) string {
for _, c := range chars {
s = strings.Replace(s, c, "", -1)
}
return s
}

func AllZero(items []uint) bool {
mask := uint(0)
for _, item := range items {
Expand Down

0 comments on commit 6333cd8

Please sign in to comment.