mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
feat: implement second level of verbosity
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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...)
|
||||
|
||||
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user