muesli/duf · error
error parsing usage-threshold: invalid option '%s'
Error message
error parsing usage-threshold: invalid option '%s'
What it means
main validates the --usage-threshold flag, which must contain exactly two comma-separated numeric values (float percentages). If splitting on "," does not yield exactly two parts, the program prints "error parsing usage-threshold: invalid option '%s'" to stderr and exits with status 1.
Source
Thrown at main.go:325
// validate availability thresholds
availbilityThresholds := strings.Split(*availThreshold, ",")
if len(availbilityThresholds) != 2 {
fmt.Fprintln(os.Stderr, fmt.Errorf("error parsing avail-threshold: invalid option '%s'", *availThreshold))
os.Exit(1)
}
for _, threshold := range availbilityThresholds {
_, err = stringToSize(threshold)
if err != nil {
fmt.Fprintln(os.Stderr, "error parsing avail-threshold:", err)
os.Exit(1)
}
}
// validate usage thresholds
usageThresholds := strings.Split(*usageThreshold, ",")
if len(usageThresholds) != 2 {
fmt.Fprintln(os.Stderr, fmt.Errorf("error parsing usage-threshold: invalid option '%s'", *usageThreshold))
os.Exit(1)
}
for _, threshold := range usageThresholds {
_, err = strconv.ParseFloat(threshold, 64)
if err != nil {
fmt.Fprintln(os.Stderr, "error parsing usage-threshold:", err)
os.Exit(1)
}
}
// print out warnings
if *warns {
for _, warning := range warnings {
fmt.Fprintln(os.Stderr, warning)
}
}
// detect terminal widthView on GitHub (pinned to 4636deb4a7)
Solutions
- Supply exactly two comma-separated floats, e.g. --usage-threshold "80,95".
- Remove stray characters/extra commas from the flag value.
- Quote the argument in shell scripts to preserve the comma-separated format.
Example fix
// before --usage-threshold 80 // after --usage-threshold "80,95"
Defensive patterns
Strategy: validation
Validate before calling
parts := strings.Split(usageThreshold, ",")
if len(parts) != 2 {
return fmt.Errorf("usage-threshold needs exactly 2 values")
}
for _, p := range parts {
if _, err := strconv.ParseFloat(p, 64); err != nil { /* invalid */ }
} Try / catch
if err := validateUsageThreshold(flag); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
} Prevention
- Always pass two comma-separated numbers like "80,95".
- Quote the flag value in shell scripts.
- Use plain floats without % signs or units.
When it happens
Trigger: Running with --usage-threshold containing anything other than two comma-separated floats, e.g. "80", "", "80,90,100", or non-numeric tokens.
Common situations: Users pass a single percentage, separate values with spaces or semicolons instead of commas, or accidentally quote the flag value twice in shell.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- error parsing avail-threshold: invalid option '%s'
- unknown style option: %s
- unknown device group: %s
- unknown column: %s (valid: %s)
- '%s' is not valid, must have integer with optional SI prefix
AI-assisted analysis of muesli/duf@4636deb4a7 (2026-09-06).
Data as JSON: /api/errors/c123a9da18232773.
Report an issue: GitHub.