Track progress of implementing Linux tree options in tree-node-cli.
-
-v— Sort by version (natural numeric sort) -
-t— Sort by last modification time -
-c— Sort by last status change time -
-U— No sorting (directory order) -
-r— Reverse sort order -
--dirsfirst— List directories before files -
--filesfirst— List files before directories -
--sort=<type>— Unified sort flag (name, version, mtime, ctime, size)
-
-f— Print full path prefix for each file- Prepend the relative path to each entry name
- CLI:
-f, --full-path - API:
fullPath: boolean
-
--prune— Remove empty directories from output- Skip directories that have no visible children after filtering
- CLI:
--prune - API:
prune: boolean
-
-i— No indentation lines- Print entries as a flat list without tree graphics
- Useful for piping output to other commands
- CLI:
-i, --no-indent - API:
noIndent: boolean
-
-p— Show file type and permissions- Display permissions like
[drwxr-xr-x]or[-rw-r--r--]before each entry - Use
fs.lstatSync().modeto get permission bits - CLI:
-p, --permissions - API:
permissions: boolean
- Display permissions like
-
-D— Show last modification time- Display mtime before each entry
- CLI:
-D, --date - API:
date: boolean
-
-Q— Quote filenames in double quotes- Wrap each filename in
"double quotes" - CLI:
-Q, --quote - API:
quote: boolean
- Wrap each filename in
-
-J— JSON output- Output the tree as a JSON structure
- CLI:
-J, --json - API:
json: boolean
- Filter before stat —
statEntriesstats all entries including hidden files that will be filtered out whenallFiles: false. Filter hidden files before stat'ing to avoid unnecessary syscalls. - Match Linux
tree -ssize behavior —computeSizesrecursively sums file sizes into parent directories, but Linuxtree -sshows each entry's ownstat.size(inode size for directories, not recursive sum).-snow usesstat.sizedirectly; recursive sums moved to new--duflag. - Merge
EXCLUDED_PATTERNSinto exclude — The hardcoded.DS_Storepattern is checked in a separate loop for every entry. Merge it into the user'sexcludearray at initialization to simplifyisExcluded. - Clarify
dirsOnlyfiltering —dirsOnlyis checked in bothisExcluded(skips files early) andfilterAndOrderContents(filters file entries). TheisExcludedcheck is a performance optimization that avoids stat'ing files, but the dual responsibility could be clearer. - Avoid mutating input arrays —
sortContentscallscontents.sort()which mutates the caller's array in place. Using[...contents].sort(...)would be safer, though not currently a bug since callers don't reuse the array.
- Each feature should include: implementation in
src/index.ts, CLI flag insrc/cli.ts, tests insrc/index.test.tsandsrc/cli.test.ts, and README docs - Match Linux
treeflag names where possible - Keep the Node.js API option names in camelCase