面向 MoonBit 的可复用通配符路径匹配与文件检索库,支持 Wasm、JS 与 Native 目标。
Dependencies
let pattern = @glob.compile_pattern("src/**/*.mbt")?
let paths = ["src/main.mbt", "src/core/parser.mbt", "README.md"]
let matched = @glob.filter_compiled_patterns([pattern], paths)let options = @glob.GlobOptions::default().files_only().sorted()
let files = @glob.glob_with_options(".", "**/*.mbt", options)?moon run cmd/main "**/*.mbt"
moon run cmd/main "src/**/*.mbt" "src"impl Show for CacheErrorpub(all) struct CachedPattern {
source : String
compiled : CompiledPattern
hits : Int
} derive(Eq, Debug)pub(all) struct CompiledPattern {
source : String
ast : AST
stats : PatternStats
prefix : String
separators : Int
recursive : Bool
segments : Int
} derive(Eq, Debug)pub(all) struct GlobPipeline {
cache : PatternCache
includes : Array[String]
excludes : Array[String]
options : GlobOptions
limit : Int?
} derive(Eq, Debug)fn GlobPipeline::run(self : GlobPipeline, paths : Array[String]) -> Result[PipelineReport, GlobError]fn GlobPipeline::run_with_cache(self : GlobPipeline, paths : Array[String]) -> Result[(GlobPipeline, PipelineReport), GlobError]fn GlobPipeline::with_limit(self : GlobPipeline, limit : Int) -> Result[GlobPipeline, PipelineError]pub(all) struct GlobQuery {
includes : Array[CompiledPattern]
excludes : Array[CompiledPattern]
options : GlobOptions
min_depth : Int
limit : Int?
} derive(Eq, Debug)pub(all) struct GlobRule {
source : String
pattern : CompiledPattern
action : RuleAction
anchored : Bool
directory_only : Bool
has_separator : Bool
} derive(Eq, Debug)pub(all) struct PatternCache {
entries : Array[CachedPattern]
capacity : Int
hits : Int
misses : Int
evictions : Int
} derive(Eq, Debug)fn PatternCache::compile_all(self : PatternCache, sources : Array[String]) -> Result[(PatternCache, Array[CompiledPattern]), GlobError]fn PatternCache::filter(self : PatternCache, source : String, paths : Array[String]) -> Result[(PatternCache, Array[String]), GlobError]fn PatternCache::get_or_compile(self : PatternCache, source : String) -> Result[(PatternCache, CompiledPattern), GlobError]fn PatternCache::match_all(self : PatternCache, sources : Array[String], path : String) -> Result[(PatternCache, Bool), GlobError]fn PatternCache::match_any(self : PatternCache, sources : Array[String], paths : Array[String]) -> Result[(PatternCache, Bool), GlobError]pub(all) struct PatternExplanation {
source : String
normalized : String
tokens : Array[String]
ast_text : String
stats : PatternStats
risk : PatternRisk
literal_prefix : String
separator_count : Int
} derive(Eq, Debug)impl Show for PipelineErrorpub(all) struct TraversalPlan {
pattern : CompiledPattern
root_prefix : String
recursive : Bool
literal : Bool
} derive(Eq, Debug)impl Show for WorkloadErrorfn dirname(path : String) -> Stringfn extension(path : String) -> String?fn filter_compiled_patterns(patterns : Array[CompiledPattern], paths : Array[String]) -> Array[String]fn filter_not_compiled_patterns(patterns : Array[CompiledPattern], paths : Array[String]) -> Array[String]fn glob_with_options(dir : String, pattern : String, options : GlobOptions) -> Result[Array[String], GlobError]fn is_hidden_path(path : String) -> Boolfn normalize_path(path : String) -> Stringfn path_depth(path : String) -> Intfn query_paths(includes : Array[String], excludes : Array[String], paths : Array[String]) -> Result[QueryReport, GlobError]面向 MoonBit 的可复用通配符路径匹配与文件检索库,支持 Wasm、JS 与 Native 目标。
Dependencies