Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix(#172): capital letters with wildcard matching #245

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,18 @@ func parseStyle(styleOpt string) (table.Style, error) {
}

// parseCommaSeparatedValues parses comma separated string into a map.
func parseCommaSeparatedValues(values string) map[string]struct{} {
func parseCommaSeparatedValues(values string, toLower bool) 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)
if toLower {
v = strings.ToLower(v)
}

m[v] = struct{}{}
}
return m
Expand Down Expand Up @@ -223,12 +226,12 @@ func main() {

// validate filters
filters := FilterOptions{
HiddenDevices: parseCommaSeparatedValues(*hideDevices),
OnlyDevices: parseCommaSeparatedValues(*onlyDevices),
HiddenFilesystems: parseCommaSeparatedValues(*hideFs),
OnlyFilesystems: parseCommaSeparatedValues(*onlyFs),
HiddenMountPoints: parseCommaSeparatedValues(*hideMp),
OnlyMountPoints: parseCommaSeparatedValues(*onlyMp),
HiddenDevices: parseCommaSeparatedValues(*hideDevices, true),
OnlyDevices: parseCommaSeparatedValues(*onlyDevices, true),
HiddenFilesystems: parseCommaSeparatedValues(*hideFs, true),
OnlyFilesystems: parseCommaSeparatedValues(*onlyFs, true),
HiddenMountPoints: parseCommaSeparatedValues(*hideMp, false),
OnlyMountPoints: parseCommaSeparatedValues(*onlyMp, false),
}
err = validateGroups(filters.HiddenDevices)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion man.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can also show and hide specific filesystems:
$ duf --only-mp /,/home,/dev
$ duf --hide-mp /,/home,/dev

Wildcards inside quotes work:
Wildcards inside quotes work and are case-sensitive:

$ duf --only-mp '/sys/*,/dev/*'

Expand Down