feat: implement second level of verbosity

This commit is contained in:
lb-a
2026-05-07 18:45:36 +02:00
parent 04cc56040b
commit 3909ba5113
3 changed files with 15 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ type globalOptions struct {
codec string
noProgress bool
noSSLVerify bool
verbose bool
verbose int
command string
commandArgs []string
}
@@ -52,7 +52,13 @@ func parseGlobalArgs(args []string) (globalOptions, error) {
case arg == "--no-ssl-verify":
opts.noSSLVerify = true
case arg == "-v" || arg == "--verbose":
opts.verbose = true
if opts.verbose < 2 {
opts.verbose++
}
case arg == "-vv":
if opts.verbose < 2 {
opts.verbose = 2
}
case arg == "-f" || arg == "--folder":
if i+1 >= len(args) {
return globalOptions{}, fmt.Errorf("%s requires a value", arg)

View File

@@ -14,6 +14,7 @@ import (
"streamrip-go/internal/app"
"streamrip-go/internal/config"
"streamrip-go/internal/provider"
"streamrip-go/internal/verbose"
_ "modernc.org/sqlite"
)
@@ -49,8 +50,11 @@ func main() {
os.Exit(1)
}
applyGlobalConfigOverrides(cfg, gopts)
if gopts.verbose {
fmt.Fprintln(os.Stderr, "verbose mode enabled")
verbose.SetLevel(gopts.verbose)
if gopts.verbose >= 2 {
fmt.Fprintln(os.Stderr, "verbose mode enabled (level 2: downloads + http)")
} else if gopts.verbose >= 1 {
fmt.Fprintln(os.Stderr, "verbose mode enabled (level 1: downloads)")
}
os.Args = append([]string{os.Args[0], gopts.command}, gopts.commandArgs...)

View File

@@ -227,7 +227,7 @@ func TestParseGlobalArgsAllOfficialFlags(t *testing.T) {
if !opts.noDB || !opts.qualitySet || opts.quality != 3 || !opts.codecSet || opts.codec != "VORBIS" {
t.Fatalf("unexpected quality/codec/db opts: %+v", opts)
}
if !opts.noProgress || !opts.noSSLVerify || !opts.verbose {
if !opts.noProgress || !opts.noSSLVerify || opts.verbose != 1 {
t.Fatalf("unexpected boolean opts: %+v", opts)
}
if opts.command != "search" {