justjavac/walkdir is a MoonBit walkdir library focused on predictable output.
It traverses directories depth-first, sorts child names lexicographically by
default, and exposes typed entries that are easy to inspect in tests or tools.
- Deterministic depth-first traversal
- Stable lexicographic ordering by default
DirEntryvalues withpath,depth, andkindwalk_fileshelper for file-only use cases- Full test coverage
moon add justjavac/walkdirpub fn walk(
root : String,
include_root? : Bool = true,
include_dirs? : Bool = true,
max_depth? : Int,
sort? : Bool = true,
) -> Array[DirEntry] raiseUse walk when you want both files and directories in a single traversal result.
include_root: include the root directory in the outputinclude_dirs: include child directories in the outputmax_depth: stop descending once the current depth reaches this valuesort: sort each directory's children before descending
pub fn walk_files(
root : String,
max_depth? : Int,
sort? : Bool = true,
) -> Array[String] raiseUse walk_files when only file paths matter.
pub(all) struct DirEntry {
path : String
depth : Int
kind : EntryKind
}Helper methods:
DirEntry::is_dir()DirEntry::is_file()
Run the bundled examples with:
moon run src/examples/collect_all --target native
moon run src/examples/files_only --target native
moon run src/examples/max_depth --target nativeLocal validation commands:
moon fmt
moon check --target all
moon test --target native -v
moon coverage analyze -p justjavac/walkdirThe coverage badge above is driven by Codecov and the Ubuntu coverage job in CI.
It updates after the main branch finishes CI and Codecov processes the
uploaded report.