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

View File

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

View File

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