Rework verbose output for visual consistency

This commit is contained in:
Seednode 2023-09-28 07:29:33 -05:00
parent 0e8ac8cdc5
commit 19c2e616fc
3 changed files with 31 additions and 21 deletions

View File

@ -498,9 +498,6 @@ func normalizePath(path string) (string, error) {
func validatePaths(args []string, formats *types.Types) ([]string, error) {
var paths []string
var pathList strings.Builder
pathList.WriteString("Paths:\n")
for i := 0; i < len(args); i++ {
path, err := normalizePath(args[i])
if err != nil {
@ -514,28 +511,34 @@ func validatePaths(args []string, formats *types.Types) ([]string, error) {
return nil, err
}
var addPath = false
switch {
case pathMatches && hasSupportedFiles:
pathList.WriteString(fmt.Sprintf("%s\n", args[i]))
addPath = true
case !pathMatches && hasSupportedFiles:
pathList.WriteString(fmt.Sprintf("%s (resolved to %s)\n", args[i], path))
addPath = true
case pathMatches && !hasSupportedFiles:
pathList.WriteString(fmt.Sprintf("%s [No supported files found]\n", args[i]))
case !pathMatches && !hasSupportedFiles:
pathList.WriteString(fmt.Sprintf("%s (resolved to %s) [No supported files found]\n", args[i], path))
}
fmt.Printf("%s | PATHS: Added %s\n",
time.Now().Format(logDate),
args[i],
)
if addPath {
paths = append(paths, path)
}
}
case !pathMatches && hasSupportedFiles:
fmt.Printf("%s | PATHS: Added %s [resolved to %s]\n",
time.Now().Format(logDate),
args[i],
path,
)
if len(paths) > 0 {
fmt.Println(pathList.String())
paths = append(paths, path)
case pathMatches && !hasSupportedFiles:
fmt.Printf("%s | PATHS: Skipped %s (No supported files found)\n",
time.Now().Format(logDate),
args[i],
)
case !pathMatches && !hasSupportedFiles:
fmt.Printf("%s | PATHS: Skipped %s [resolved to %s] (No supported files found)\n",
time.Now().Format(logDate),
args[i],
path,
)
}
}
return paths, nil

View File

@ -12,7 +12,7 @@ import (
)
const (
ReleaseVersion string = "1.1.0"
ReleaseVersion string = "1.2.0"
)
var (

View File

@ -385,6 +385,13 @@ func redirectRoot() httprouter.Handle {
}
func ServePage(args []string) error {
if Verbose {
fmt.Printf("%s | START: roulette v%s\n",
time.Now().Format(logDate),
ReleaseVersion,
)
}
timeZone := os.Getenv("TZ")
if timeZone != "" {
var err error