muesli/duf · error
unknown style option: %s
Error message
unknown style option: %s
What it means
parseStyle maps the --style CLI option to a tablewriter style. Only "unicode" (table.StyleRounded) and "ascii" (table.StyleDefault) are accepted; any other value returns "unknown style option: %s". It is a strict enum validation of a user-supplied flag.
Source
Thrown at main.go:99
if err != nil {
return nil, err
}
i = append(i, col)
}
return i, nil
}
// parseStyle converts user-provided style option into a table.Style.
func parseStyle(styleOpt string) (table.Style, error) {
switch styleOpt {
case "unicode":
return table.StyleRounded, nil
case "ascii":
return table.StyleDefault, nil
default:
return table.Style{}, fmt.Errorf("unknown style option: %s", styleOpt)
}
}
// parseCommaSeparatedValues parses comma separated string into a map.
func parseCommaSeparatedValues(values string) map[string]struct{} {
m := make(map[string]struct{})
for _, v := range strings.Split(values, ",") {
v = strings.TrimSpace(v)
if len(v) == 0 {
continue
}
v = strings.ToLower(v)
m[v] = struct{}{}
}
return m
}
View on GitHub (pinned to 4636deb4a7)
Solutions
- Run with --style unicode or --style ascii exactly as lowercase.
- Check the tool's help output for the accepted style values.
- If you control the code, normalize input with strings.ToLower before the switch and/or add the desired style as a new case.
Example fix
// before
switch styleOpt {
case "unicode": return table.StyleRounded, nil
case "ascii": return table.StyleDefault, nil
}
// after
switch strings.ToLower(styleOpt) {
case "unicode", "rounded": return table.StyleRounded, nil
case "ascii", "default": return table.StyleDefault, nil
} Defensive patterns
Strategy: validation
Validate before calling
validStyles := map[string]bool{"unicode": true, "ascii": true}
if !validStyles[style] {
return fmt.Errorf("style must be unicode or ascii, got %q", style)
} Try / catch
style, err := parseStyle(styleOpt)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
} Prevention
- Only pass unicode or ascii (lowercase) as --style.
- Normalize with strings.ToLower before validating.
- Check --help for accepted values.
When it happens
Trigger: Calling the binary with --style set to anything other than "unicode" or "ascii", e.g. --style rounded, --style fancy, --style UNICODE (case-sensitive).
Common situations: Users guess at style names, copy a style name from another table library, or capitalize the value expecting case-insensitive handling.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- unknown device group: %s
- error parsing avail-threshold: invalid option '%s'
- error parsing usage-threshold: invalid option '%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/2366fbb605d0cc11.
Report an issue: GitHub.