better logging

This commit is contained in:
Jay Gabriels
2022-07-31 15:38:59 -07:00
parent b791554c78
commit ddacc20e44
2 changed files with 22 additions and 9 deletions

View File

@@ -196,7 +196,6 @@ func cloneFunc(cmd *cobra.Command, argz []string) {
os.Setenv("GHORG_GITEA_TOKEN", cmd.Flag("token").Value.String())
}
}
err := configs.VerifyTokenSet()
if err != nil {
colorlog.PrintError(err)
@@ -836,7 +835,7 @@ func PrintConfigs() {
colorlog.PrintInfo("* Exclude Regex : " + os.Getenv("GHORG_EXCLUDE_MATCH_REGEX"))
}
if os.Getenv("GHORG_MATCH_PREFIX") != "" {
colorlog.PrintInfo("* Prefix Match: " + os.Getenv("GHORG_MATCH_PREFIX"))
colorlog.PrintInfo("* Prefix Match : " + os.Getenv("GHORG_MATCH_PREFIX"))
}
if os.Getenv("GHORG_EXCLUDE_MATCH_PREFIX") != "" {
colorlog.PrintInfo("* Exclude Prefix: " + os.Getenv("GHORG_EXCLUDE_MATCH_PREFIX"))

View File

@@ -54,6 +54,20 @@ func reCloneFunc(cmd *cobra.Command, argz []string) {
}
}
printFinalOutput(argz, mapOfReClones)
}
func printFinalOutput(argz []string, reCloneMap map[string]ReClone) {
if len(argz) == 0 {
for key, value := range reCloneMap {
fmt.Printf("%v: %v\n", key, value)
}
} else {
for _, arg := range argz {
key, value := reCloneMap[arg]
fmt.Printf("%v: %v\n", key, value)
}
}
}
func runReClone(rc ReClone) {
@@ -72,17 +86,17 @@ func runReClone(rc ReClone) {
colorlog.PrintErrorAndExit(e)
}
err = ghorgClone.Start()
if err != nil {
e := fmt.Sprintf("ERROR: Running ghorg clone cmd: %v, err: %v", rc.Cmd, err)
colorlog.PrintErrorAndExit(e)
}
ghorgClone.Start()
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
m := scanner.Text()
fmt.Println(m)
}
ghorgClone.Wait()
err = ghorgClone.Wait()
if err != nil {
e := fmt.Sprintf("ERROR: Running ghorg clone cmd: %v, err: %v", rc.Cmd, err)
colorlog.PrintErrorAndExit(e)
}
}