From 8d013c9375944c46affa7dc177754857402f7db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6k=C3=A7ehan=20Kara?= Date: Sat, 2 Sep 2023 22:22:56 +0300 Subject: [PATCH] add 'setlocal' for directory specific options (#1381) * add 'setlocal' for option 'sortby' * save each local option separately * add 'setlocal' for option 'reverse' * add 'setlocal' for option 'dirfirst' * add 'setlocal' for option 'hidden' * add 'setlocal' for option 'dironly' * add 'setlocal' for option 'info' * add boolean toggling for 'setlocal' options * check if the path is absolute for 'setlocal' * add 'setlocal' options to completion * add tests for 'setlocal' * add 'setlocal' to the documentation * use trailing '/' in 'setlocal' for subdir matching * cleanup * add 'setlocal' subdirs to the documentation --- complete.go | 23 ++++++- doc.go | 17 ++++- docstring.go | 21 +++++- eval.go | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++ eval_test.go | 78 ++++++++++++++++++++++ lf.1 | 17 ++++- nav.go | 10 +-- opts.go | 97 +++++++++++++++++++++++++++- parse.go | 73 +++++++++++++++------ ui.go | 2 +- 10 files changed, 486 insertions(+), 31 deletions(-) diff --git a/complete.go b/complete.go index 57172547..b43a4248 100644 --- a/complete.go +++ b/complete.go @@ -11,6 +11,7 @@ import ( var ( gCmdWords = []string{ "set", + "setlocal", "map", "maps", "cmap", @@ -224,6 +225,23 @@ var ( "truncatechar", "truncatepct", } + + gLocalOptWords = []string{ + "dirfirst", + "nodirfirst", + "dirfirst!", + "dironly", + "nodironly", + "dironly!", + "hidden", + "nohidden", + "hidden!", + "info", + "reverse", + "noreverse", + "reverse!", + "sortby", + } ) func matchLongest(s1, s2 []rune) []rune { @@ -410,6 +428,9 @@ func completeCmd(acc []rune) (matches []string, longestAcc []rune) { } case 3: switch f[0] { + case "setlocal": + matches, longest = matchWord(f[2], gLocalOptWords) + longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...) case "map", "cmap": matches, longest = matchCmd(f[2]) longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...) @@ -419,7 +440,7 @@ func completeCmd(acc []rune) (matches []string, longestAcc []rune) { } default: switch f[0] { - case "set", "map", "cmap", "cmd": + case "set", "setlocal", "map", "cmap", "cmd": longestAcc = acc default: matches, longest = matchFile(f[len(f)-1]) diff --git a/doc.go b/doc.go index a4298728..4e43332c 100644 --- a/doc.go +++ b/doc.go @@ -1125,7 +1125,7 @@ Characters from '#' to newline are comments and ignored: # comments start with '#' -There are four special commands ('set', 'map', 'cmap', and 'cmd') for configuration. +There are five special commands ('set', 'setlocal', 'map', 'cmap', and 'cmd') for configuration. Command 'set' is used to set an option which can be boolean, integer, or string: @@ -1139,6 +1139,21 @@ Command 'set' is used to set an option which can be boolean, integer, or string: set sortby 'time' # string value with single quotes (whitespaces) set sortby "time" # string value with double quotes (backslash escapes) +Command 'setlocal' is used to set a local option for a directory which can be boolean or string. +Currently supported local options are 'dirfirst', 'dironly', 'hidden', 'info', 'reverse', and 'sortby'. +Adding a trailing path separator (i.e. '/' for Unix and '\' for Windows) sets the option for the given directory along with its subdirectories: + + setlocal /foo/bar hidden # boolean enable + setlocal /foo/bar hidden true # boolean enable + setlocal /foo/bar nohidden # boolean disable + setlocal /foo/bar hidden false # boolean disable + setlocal /foo/bar hidden! # boolean toggle + setlocal /foo/bar sortby time # string value w/o quotes + setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) + setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) + setlocal /foo/bar hidden # for only '/foo/bar' directory + setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') + Command 'map' is used to bind a key to a command which can be builtin command, custom command, or shell command: map gh cd ~ # builtin command diff --git a/docstring.go b/docstring.go index 11062943..4facbb20 100644 --- a/docstring.go +++ b/docstring.go @@ -1211,8 +1211,8 @@ Characters from '#' to newline are comments and ignored: # comments start with '#' -There are four special commands ('set', 'map', 'cmap', and 'cmd') for -configuration. +There are five special commands ('set', 'setlocal', 'map', 'cmap', and 'cmd') +for configuration. Command 'set' is used to set an option which can be boolean, integer, or string: @@ -1226,6 +1226,23 @@ Command 'set' is used to set an option which can be boolean, integer, or string: set sortby 'time' # string value with single quotes (whitespaces) set sortby "time" # string value with double quotes (backslash escapes) +Command 'setlocal' is used to set a local option for a directory which can be +boolean or string. Currently supported local options are 'dirfirst', 'dironly', +'hidden', 'info', 'reverse', and 'sortby'. Adding a trailing path separator +(i.e. '/' for Unix and '\' for Windows) sets the option for the given directory +along with its subdirectories: + + setlocal /foo/bar hidden # boolean enable + setlocal /foo/bar hidden true # boolean enable + setlocal /foo/bar nohidden # boolean disable + setlocal /foo/bar hidden false # boolean disable + setlocal /foo/bar hidden! # boolean toggle + setlocal /foo/bar sortby time # string value w/o quotes + setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) + setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) + setlocal /foo/bar hidden # for only '/foo/bar' directory + setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') + Command 'map' is used to bind a key to a command which can be builtin command, custom command, or shell command: diff --git a/eval.go b/eval.go index 362efb4f..101f92f8 100644 --- a/eval.go +++ b/eval.go @@ -924,6 +924,185 @@ func (e *setExpr) eval(app *app, args []string) { app.ui.loadFileInfo(app.nav) } +func (e *setLocalExpr) eval(app *app, args []string) { + path := replaceTilde(e.path) + if !filepath.IsAbs(path) { + app.ui.echoerr("setlocal: path should be absolute") + return + } + + switch e.opt { + case "dirfirst": + if e.val == "" || e.val == "true" { + gLocalOpts.dirfirsts[path] = true + } else if e.val == "false" { + gLocalOpts.dirfirsts[path] = false + } else { + app.ui.echoerr("dirfirst: value should be empty, 'true', or 'false'") + return + } + app.nav.sort() + app.ui.sort() + case "nodirfirst": + if e.val != "" { + app.ui.echoerrf("nodirfirst: unexpected value: %s", e.val) + return + } + gLocalOpts.dirfirsts[path] = false + app.nav.sort() + app.ui.sort() + case "dirfirst!": + if e.val != "" { + app.ui.echoerrf("dirfirst!: unexpected value: %s", e.val) + return + } + if val, ok := gLocalOpts.dirfirsts[path]; ok { + gLocalOpts.dirfirsts[path] = !val + } else { + val = gOpts.sortType.option&dirfirstSort != 0 + gLocalOpts.dirfirsts[path] = !val + } + app.nav.sort() + app.ui.sort() + case "dironly": + if e.val == "" || e.val == "true" { + gLocalOpts.dironlys[path] = true + } else if e.val == "false" { + gLocalOpts.dironlys[path] = false + } else { + app.ui.echoerr("dironly: value should be empty, 'true', or 'false'") + return + } + app.nav.sort() + app.ui.sort() + case "nodironly": + if e.val != "" { + app.ui.echoerrf("nodironly: unexpected value: %s", e.val) + return + } + gLocalOpts.dironlys[path] = false + app.nav.sort() + app.ui.sort() + case "dironly!": + if e.val != "" { + app.ui.echoerrf("dironly!: unexpected value: %s", e.val) + return + } + if val, ok := gLocalOpts.dironlys[path]; ok { + gLocalOpts.dironlys[path] = !val + } else { + gLocalOpts.dironlys[path] = !gOpts.dironly + } + app.nav.sort() + app.ui.sort() + case "hidden": + if e.val == "" || e.val == "true" { + gLocalOpts.hiddens[path] = true + } else if e.val == "false" { + gLocalOpts.hiddens[path] = false + } else { + app.ui.echoerr("hidden: value should be empty, 'true', or 'false'") + return + } + app.nav.sort() + app.ui.sort() + case "nohidden": + if e.val != "" { + app.ui.echoerrf("nohidden: unexpected value: %s", e.val) + return + } + gLocalOpts.hiddens[path] = false + app.nav.sort() + app.ui.sort() + case "hidden!": + if e.val != "" { + app.ui.echoerrf("hidden!: unexpected value: %s", e.val) + return + } + if val, ok := gLocalOpts.hiddens[path]; ok { + gLocalOpts.hiddens[path] = !val + } else { + val = gOpts.sortType.option&hiddenSort != 0 + gLocalOpts.hiddens[path] = !val + } + app.nav.sort() + app.ui.sort() + case "info": + if e.val == "" { + gLocalOpts.infos[path] = nil + return + } + toks := strings.Split(e.val, ":") + for _, s := range toks { + switch s { + case "size", "time", "atime", "ctime": + default: + app.ui.echoerr("info: should consist of 'size', 'time', 'atime' or 'ctime' separated with colon") + return + } + } + gLocalOpts.infos[path] = toks + case "reverse": + if e.val == "" || e.val == "true" { + gLocalOpts.reverses[path] = true + } else if e.val == "false" { + gLocalOpts.reverses[path] = false + } else { + app.ui.echoerr("reverse: value should be empty, 'true', or 'false'") + return + } + app.nav.sort() + app.ui.sort() + case "noreverse": + if e.val != "" { + app.ui.echoerrf("noreverse: unexpected value: %s", e.val) + return + } + gLocalOpts.reverses[path] = false + app.nav.sort() + app.ui.sort() + case "reverse!": + if e.val != "" { + app.ui.echoerrf("reverse!: unexpected value: %s", e.val) + return + } + if val, ok := gLocalOpts.reverses[path]; ok { + gLocalOpts.reverses[path] = !val + } else { + val = gOpts.sortType.option&reverseSort != 0 + gLocalOpts.reverses[path] = !val + } + app.nav.sort() + app.ui.sort() + case "sortby": + switch e.val { + case "natural": + gLocalOpts.sortMethods[path] = naturalSort + case "name": + gLocalOpts.sortMethods[path] = nameSort + case "size": + gLocalOpts.sortMethods[path] = sizeSort + case "time": + gLocalOpts.sortMethods[path] = timeSort + case "ctime": + gLocalOpts.sortMethods[path] = ctimeSort + case "atime": + gLocalOpts.sortMethods[path] = atimeSort + case "ext": + gLocalOpts.sortMethods[path] = extSort + default: + app.ui.echoerr("sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'ctime' or 'ext'") + return + } + app.nav.sort() + app.ui.sort() + default: + app.ui.echoerrf("unknown option: %s", e.opt) + return + } + app.ui.loadFileInfo(app.nav) +} + func (e *mapExpr) eval(app *app, args []string) { if e.expr == nil { delete(gOpts.keys, e.keys) diff --git a/eval_test.go b/eval_test.go index 48cb4457..2d13118a 100644 --- a/eval_test.go +++ b/eval_test.go @@ -191,6 +191,84 @@ var gEvalTests = []struct { []expr{&setExpr{"ratios", "1:2:3"}, &setExpr{"hidden", ""}}, }, + { + "setlocal /foo/bar hidden # trailing comments are allowed", + []string{"setlocal", "/foo/bar", "hidden", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "hidden", ""}}, + }, + + { + "setlocal /foo/bar hidden; setlocal /foo/bar reverse", + []string{"setlocal", "/foo/bar", "hidden", ";", "setlocal", "/foo/bar", "reverse", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "hidden", ""}, &setLocalExpr{"/foo/bar", "reverse", ""}}, + }, + + { + "setlocal /foo/bar hidden\nsetlocal /foo/bar reverse", + []string{"setlocal", "/foo/bar", "hidden", "\n", "setlocal", "/foo/bar", "reverse", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "hidden", ""}, &setLocalExpr{"/foo/bar", "reverse", ""}}, + }, + + { + `setlocal /foo/bar info ""`, + []string{"setlocal", "/foo/bar", "info", "", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "info", ""}}, + }, + + { + `setlocal /foo/bar info "size"`, + []string{"setlocal", "/foo/bar", "info", "size", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "info", "size"}}, + }, + + { + "setlocal /foo/bar info size:time", + []string{"setlocal", "/foo/bar", "info", "size:time", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "info", "size:time"}}, + }, + + { + "setlocal /foo/bar info size:time;", + []string{"setlocal", "/foo/bar", "info", "size:time", ";"}, + []expr{&setLocalExpr{"/foo/bar", "info", "size:time"}}, + }, + + { + ":setlocal /foo/bar info size:time", + []string{":", "setlocal", "/foo/bar", "info", "size:time", "\n", "\n"}, + []expr{&listExpr{[]expr{&setLocalExpr{"/foo/bar", "info", "size:time"}}, 1}}, + }, + + { + ":setlocal /foo/bar info size:time\nsetlocal /foo/bar hidden", + []string{":", "setlocal", "/foo/bar", "info", "size:time", "\n", "\n", "setlocal", "/foo/bar", "hidden", "\n"}, + []expr{&listExpr{[]expr{&setLocalExpr{"/foo/bar", "info", "size:time"}}, 1}, &setLocalExpr{"/foo/bar", "hidden", ""}}, + }, + + { + ":setlocal /foo/bar info size:time;", + []string{":", "setlocal", "/foo/bar", "info", "size:time", ";", "\n"}, + []expr{&listExpr{[]expr{&setLocalExpr{"/foo/bar", "info", "size:time"}}, 1}}, + }, + + { + ":setlocal /foo/bar info size:time;\nsetlocal /foo/bar hidden", + []string{":", "setlocal", "/foo/bar", "info", "size:time", ";", "\n", "setlocal", "/foo/bar", "hidden", "\n"}, + []expr{&listExpr{[]expr{&setLocalExpr{"/foo/bar", "info", "size:time"}}, 1}, &setLocalExpr{"/foo/bar", "hidden", ""}}, + }, + + { + "setlocal /foo/bar info size:time\n setlocal /foo/bar hidden", + []string{"setlocal", "/foo/bar", "info", "size:time", "\n", "setlocal", "/foo/bar", "hidden", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "info", "size:time"}, &setLocalExpr{"/foo/bar", "hidden", ""}}, + }, + + { + "setlocal /foo/bar info size:time \nsetlocal /foo/bar hidden", + []string{"setlocal", "/foo/bar", "info", "size:time", "\n", "setlocal", "/foo/bar", "hidden", "\n"}, + []expr{&setLocalExpr{"/foo/bar", "info", "size:time"}, &setLocalExpr{"/foo/bar", "hidden", ""}}, + }, + { "map gh cd ~", []string{"map", "gh", "cd", "~", "\n"}, diff --git a/lf.1 b/lf.1 index a84277d9..4d238fa8 100644 --- a/lf.1 +++ b/lf.1 @@ -1349,7 +1349,7 @@ Characters from '#' to newline are comments and ignored: # comments start with '#' .EE .PP -There are four special commands ('set', 'map', 'cmap', and 'cmd') for configuration. +There are five special commands ('set', 'setlocal', 'map', 'cmap', and 'cmd') for configuration. .PP Command 'set' is used to set an option which can be boolean, integer, or string: .PP @@ -1365,6 +1365,21 @@ Command 'set' is used to set an option which can be boolean, integer, or string: set sortby "time" # string value with double quotes (backslash escapes) .EE .PP +Command 'setlocal' is used to set a local option for a directory which can be boolean or string. Currently supported local options are 'dirfirst', 'dironly', 'hidden', 'info', 'reverse', and 'sortby'. Adding a trailing path separator (i.e. '/' for Unix and '\e' for Windows) sets the option for the given directory along with its subdirectories: +.PP +.EX + setlocal /foo/bar hidden # boolean enable + setlocal /foo/bar hidden true # boolean enable + setlocal /foo/bar nohidden # boolean disable + setlocal /foo/bar hidden false # boolean disable + setlocal /foo/bar hidden! # boolean toggle + setlocal /foo/bar sortby time # string value w/o quotes + setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) + setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) + setlocal /foo/bar hidden # for only '/foo/bar' directory + setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') +.EE +.PP Command 'map' is used to bind a key to a command which can be builtin command, custom command, or shell command: .PP .EX diff --git a/nav.go b/nav.go index 111ccb90..8889f54f 100644 --- a/nav.go +++ b/nav.go @@ -210,8 +210,8 @@ func normalize(s1, s2 string, ignorecase, ignoredia bool) (string, string) { } func (dir *dir) sort() { - dir.sortType = gOpts.sortType - dir.dironly = gOpts.dironly + dir.sortType = getSortType(dir.path) + dir.dironly = getDirOnly(dir.path) dir.hiddenfiles = gOpts.hiddenfiles dir.ignorecase = gOpts.ignorecase dir.ignoredia = gOpts.ignoredia @@ -472,7 +472,7 @@ func (nav *nav) loadDirInternal(path string) *dir { loading: true, loadTime: time.Now(), path: path, - sortType: gOpts.sortType, + sortType: getSortType(path), hiddenfiles: gOpts.hiddenfiles, ignorecase: gOpts.ignorecase, ignoredia: gOpts.ignoredia, @@ -535,8 +535,8 @@ func (nav *nav) checkDir(dir *dir) { } nav.dirChan <- nd }() - case dir.sortType != gOpts.sortType || - dir.dironly != gOpts.dironly || + case dir.sortType != getSortType(dir.path) || + dir.dironly != getDirOnly(dir.path) || !reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) || dir.ignorecase != gOpts.ignorecase || dir.ignoredia != gOpts.ignoredia: diff --git a/opts.go b/opts.go index 30e2c0e8..d04d305e 100644 --- a/opts.go +++ b/opts.go @@ -1,6 +1,9 @@ package main -import "time" +import ( + "path/filepath" + "time" +) type sortMethod byte @@ -92,6 +95,91 @@ var gOpts struct { tagfmt string } +var gLocalOpts struct { + sortMethods map[string]sortMethod + dirfirsts map[string]bool + dironlys map[string]bool + hiddens map[string]bool + reverses map[string]bool + infos map[string][]string +} + +func localOptPaths(path string) []string { + var list []string + list = append(list, path) + for curr := path; !isRoot(curr); curr = filepath.Dir(curr) { + list = append(list, curr+string(filepath.Separator)) + } + return list +} + +func getSortMethod(path string) sortMethod { + for _, key := range localOptPaths(path) { + if val, ok := gLocalOpts.sortMethods[key]; ok { + return val + } + } + return gOpts.sortType.method +} + +func getSortType(path string) sortType { + method := getSortMethod(path) + option := gOpts.sortType.option + for _, key := range localOptPaths(path) { + if val, ok := gLocalOpts.dirfirsts[key]; ok { + if val { + option |= dirfirstSort + } else { + option &= ^dirfirstSort + } + break + } + } + for _, key := range localOptPaths(path) { + if val, ok := gLocalOpts.hiddens[key]; ok { + if val { + option |= hiddenSort + } else { + option &= ^hiddenSort + } + break + } + } + for _, key := range localOptPaths(path) { + if val, ok := gLocalOpts.reverses[key]; ok { + if val { + option |= reverseSort + } else { + option &= ^reverseSort + } + break + } + } + val := sortType{ + method: method, + option: option, + } + return val +} + +func getDirOnly(path string) bool { + for _, key := range localOptPaths(path) { + if val, ok := gLocalOpts.dironlys[key]; ok { + return val + } + } + return gOpts.dironly +} + +func getInfo(path string) []string { + for _, key := range localOptPaths(path) { + if val, ok := gLocalOpts.infos[key]; ok { + return val + } + } + return gOpts.info +} + func init() { gOpts.anchorfind = true gOpts.autoquit = false @@ -268,5 +356,12 @@ func init() { gOpts.cmds = make(map[string]expr) gOpts.user = make(map[string]string) + gLocalOpts.sortMethods = make(map[string]sortMethod) + gLocalOpts.dirfirsts = make(map[string]bool) + gLocalOpts.dironlys = make(map[string]bool) + gLocalOpts.hiddens = make(map[string]bool) + gLocalOpts.reverses = make(map[string]bool) + gLocalOpts.infos = make(map[string][]string) + setDefaults() } diff --git a/parse.go b/parse.go index e6abeb00..f6ba4e77 100644 --- a/parse.go +++ b/parse.go @@ -2,34 +2,37 @@ package main // Grammar of the language used in the evaluator // -// Expr = SetExpr -// | MapExpr -// | CMapExpr -// | CmdExpr -// | CallExpr -// | ExecExpr -// | ListExpr +// Expr = SetExpr +// | SetLocalExpr +// | MapExpr +// | CMapExpr +// | CmdExpr +// | CallExpr +// | ExecExpr +// | ListExpr // -// SetExpr = 'set' ';' +// SetExpr = 'set' ';' // -// MapExpr = 'map' Expr +// SetLocalExpr = 'setlocal' ';' // -// CMapExpr = 'cmap' Expr +// MapExpr = 'map' Expr // -// CmdExpr = 'cmd' Expr +// CMapExpr = 'cmap' Expr // -// CallExpr = ';' +// CmdExpr = 'cmd' Expr // -// ExecExpr = Prefix '\n' -// | Prefix '{{' '}}' ';' +// CallExpr = ';' // -// Prefix = '$' | '%' | '!' | '&' +// ExecExpr = Prefix '\n' +// | Prefix '{{' '}}' ';' // -// ListExpr = ':' Expr ListRest '\n' -// | ':' '{{' Expr ListRest '}}' ';' +// Prefix = '$' | '%' | '!' | '&' // -// ListRest = Nil -// | Expr ListExpr +// ListExpr = ':' Expr ListRest '\n' +// | ':' '{{' Expr ListRest '}}' ';' +// +// ListRest = Nil +// | Expr ListExpr import ( "bytes" @@ -50,6 +53,14 @@ type setExpr struct { func (e *setExpr) String() string { return fmt.Sprintf("set %s %s", e.opt, e.val) } +type setLocalExpr struct { + path string + opt string + val string +} + +func (e *setLocalExpr) String() string { return fmt.Sprintf("setlocal %s %s %s", e.path, e.opt, e.val) } + type mapExpr struct { keys string expr expr @@ -176,6 +187,30 @@ func (p *parser) parseExpr() expr { s.scan() result = &setExpr{opt, val} + case "setlocal": + var val string + + s.scan() + if s.typ != tokenIdent { + p.err = fmt.Errorf("expected directory: %s", s.tok) + } + dir := s.tok + + s.scan() + if s.typ != tokenIdent { + p.err = fmt.Errorf("expected identifier: %s", s.tok) + } + opt := s.tok + + s.scan() + if s.typ != tokenSemicolon { + val = s.tok + s.scan() + } + + s.scan() + + result = &setLocalExpr{dir, opt, val} case "map": var expr expr diff --git a/ui.go b/ui.go index b3cea36d..6861f7e8 100644 --- a/ui.go +++ b/ui.go @@ -290,7 +290,7 @@ func infotimefmt(t time.Time) string { func fileInfo(f *file, d *dir) string { var info string - for _, s := range gOpts.info { + for _, s := range getInfo(d.path) { switch s { case "size": if !(f.IsDir() && gOpts.dircounts) {