feat(cli): add --strict flag to fail track download if quality is unavailable

This commit is contained in:
Mathis Maquenne
2025-08-09 19:17:29 +02:00
parent 7154c15cc3
commit 283c5d76e9
3 changed files with 15 additions and 4 deletions
+10 -3
View File
@@ -14,16 +14,23 @@ var validQualities = map[string]bool{
type Options struct {
Quality string
Timeout time.Duration
BPM bool
Limit int
BPM bool
Strict bool
}
func (o *Options) Validate() error {
if !validQualities[o.Quality] {
return fmt.Errorf("invalid quality option: %s", o.Quality)
}
if o.Limit < 0 {
return fmt.Errorf("limit must be a non-negative integer")
if o.Timeout <= 0 {
return fmt.Errorf("timeout must be a positive duration")
}
if o.Limit <= 0 {
return fmt.Errorf("limit must be a positive integer")
}
if o.Limit > 100 {
return fmt.Errorf("limit must not exceed 100")
}
return nil