Recursively find and optionally wipe MoonBit build directories
moon binstall f4ah6o/moon-wipemoon binstall f4ah6o/moon-wipe/cmd/moon-wipemoon install --path ./cmd/moon-wipe
# => ~/.moon/bin/moon-wipemoon-wipe [TARGET] [OPTIONS]| Target | Looks for | Marker |
|---|---|---|
| moon (default) | _build | .moon_db |
| mooncakes | .mooncakes | .moon-lock |
| all | both of the above | |
| cache | $MOON_HOME/cache, $MOON_HOME/registry |
$ moon-wipe
moon-wipe 0.1.0
Searching for MoonBit build directories in /home/you/code
/home/you/code/a/_build 1.2 GiB 1,234 files
/home/you/code/b/_build 340.5 MiB 567 files
Found 2 directories, 1.5 GiB, 1,801 files
Dry run: re-run with -w to delete$ moon-wipe -w
...
Wiped 2 directories, freed 1.5 GiB| Flag | Meaning |
|---|---|
| -w, --wipe | Delete what was found |
| -i, --ignore <PATH> | Skip this path; repeatable |
| --root <PATH> | Start searching here (default: current directory) |
| --min-size <SIZE> | Only report directories at least this large |
| --older-than <DAYS> | Only report directories untouched for this many days |
| --json | Emit machine-readable JSON |
| -h, --help | Print help |
| -V, --version | Print the version |
_build/native/debug/build/.mooncakes/...///|
test {
let options = @moon-wipe.Options::new()
inspect(options.target.name(), content="moon")
inspect(options.wipe, content="false")
}///|
test {
inspect(@moon-wipe.format_bytes(1536), content="1.5 KiB")
inspect(@moon-wipe.group_digits(1234567), content="1,234,567")
}///|
test {
debug_inspect(
@moon-wipe.cache_dirs_from("/home/u/.moon", None, None),
content="[\"/home/u/.moon/cache\", \"/home/u/.moon/registry\"]",
)
}moon check
moon test
moon fmtmoon run scripts/version.mbtx syncpub(all) suberror CliError {
CliError(String)
}pub(all) suberror ScanError {
ScanError(String)
}pub(all) struct Entry {
path : String
size : Int64
files : Int
ignored : Bool
error : String?
} derive(Debug)test {
inspect(@moon-wipe.Target::Moon.name(), content="moon")
inspect(@moon-wipe.Target::Mooncakes.name(), content="mooncakes")
inspect(@moon-wipe.Target::All.name(), content="all")
inspect(@moon-wipe.Target::Cache.name(), content="cache")
}test {
debug_inspect(@moon-wipe.Target::parse("moon"), content="Moon")
debug_inspect(@moon-wipe.Target::parse(" mooncakes "), content="Mooncakes")
debug_inspect(@moon-wipe.Target::parse("all"), content="All")
debug_inspect(@moon-wipe.Target::parse("cache"), content="Cache")
}test {
debug_inspect(
@moon-wipe.Target::Moon.rules(),
content="[{ dir_name: \"_build\", marker: \".moon_db\" }]",
)
debug_inspect(@moon-wipe.Target::All.rules().length(), content="2")
debug_inspect(@moon-wipe.Target::Cache.rules().length(), content="0")
}let VERSION : Stringfn cache_dirs_from(home : StringView, dep_cache : String?, registry_cache : String?) -> Array[String]test {
debug_inspect(
@moon-wipe.cache_dirs_from("/home/u/.moon", None, None),
content="[\"/home/u/.moon/cache\", \"/home/u/.moon/registry\"]",
)
debug_inspect(
@moon-wipe.cache_dirs_from("/home/u/.moon", Some("/d"), Some("/r")),
content="[\"/d\", \"/r\"]",
)
}async fn dir_size(path : StringView) -> (Int64, Int)fn format_bytes(bytes : Int64) -> Stringtest {
inspect(@moon-wipe.format_bytes(0), content="0 B")
inspect(@moon-wipe.format_bytes(512), content="512 B")
inspect(@moon-wipe.format_bytes(1024), content="1.0 KiB")
inspect(@moon-wipe.format_bytes(1536), content="1.5 KiB")
inspect(@moon-wipe.format_bytes(1048576), content="1.0 MiB")
inspect(@moon-wipe.format_bytes(1099511627776), content="1.0 TiB")
}fn group_digits(value : Int64) -> Stringtest {
inspect(@moon-wipe.group_digits(0), content="0")
inspect(@moon-wipe.group_digits(999), content="999")
inspect(@moon-wipe.group_digits(1000), content="1,000")
inspect(@moon-wipe.group_digits(1234567), content="1,234,567")
}fn join(dir : StringView, name : StringView) -> Stringtest {
inspect(@moon-wipe.join("/a", "b"), content="/a/b")
inspect(@moon-wipe.join("/a/", "b"), content="/a/b")
inspect(@moon-wipe.join("/", "b"), content="/b")
}test {
let command = @moon-wipe.parse_args(["-w", "mooncakes"])
guard command is Run(options) else { fail("expected Run") }
inspect(options.wipe, content="true")
debug_inspect(options.target, content="Mooncakes")
}test {
inspect(@moon-wipe.parse_size("100"), content="100")
inspect(@moon-wipe.parse_size("1K"), content="1024")
inspect(@moon-wipe.parse_size("1.5M"), content="1572864")
inspect(@moon-wipe.parse_size("2GiB"), content="2147483648")
}fn strip_trailing_slash(path : StringView) -> Stringtest {
inspect(@moon-wipe.strip_trailing_slash("/a/b/"), content="/a/b")
inspect(@moon-wipe.strip_trailing_slash("/a/b///"), content="/a/b")
inspect(@moon-wipe.strip_trailing_slash("/"), content="/")
inspect(@moon-wipe.strip_trailing_slash("/a/b"), content="/a/b")
}Install
Download zipRecursively find and optionally wipe MoonBit build directories