glob icon indicating copy to clipboard operation
glob copied to clipboard

can walkGlobKinds be refactored to call something like glob from https://github.com/nim-lang/Nim/pull/15598 ?

Open timotheecour opened this issue 5 years ago • 2 comments

followup from https://github.com/nim-lang/Nim/pull/15598#issuecomment-710501415

the idea would be to benefit from features introduced in https://github.com/nim-lang/Nim/pull/15598 by providing a wrapper around std/globs while retaining the same interface in pkg/glob

it would work like this:

# in pkg/glob
import std/globs
iterator walkGlobKinds* (
  pattern: string | Glob,
  root = "",
  options = defaultGlobOptions,
  filterDescend: FilterDescend = nil,
  filterYield: FilterYield = nil
): GlobEntry =
  proc filterDescend2(entry: PathEntry): bool = filterDescend(entry.path, entry.kind)
  let dir = # compute from options
  for entry in glob(dir, follow = filterDescend2, ...):
    if filterYield(postprocess(entry)):
      yield toGlobEntry(entry)

timotheecour avatar Oct 16 '20 19:10 timotheecour

This relies on the outcome of https://github.com/nim-lang/Nim/pull/15598 which would need to be accepted into Nim's standard library or elsewhere for this package to use it as a dependency.

haltcase avatar Oct 16 '20 20:10 haltcase

I mean on a technical level, wherever that linked PR ends (eg fusion or another nimble package)

timotheecour avatar Oct 16 '20 21:10 timotheecour