chrisant996 / clink

Bash's powerful command line editing in cmd.exe
https://chrisant996.github.io/clink/
GNU General Public License v3.0
3.63k stars 143 forks source link

Documentation for `globpattern` missing #443

Closed sebthom closed 1 year ago

sebthom commented 1 year ago

I was looking for a documentation what glob pattern features are supported by os.globFiles() but couldn't find anything.

I want something like os.globFiles("**/*.{yml,yaml}")) but that does not work.

chrisant996 commented 1 year ago

Martin called it "glob" but he meant it in the loose sense. You're thinking of GNU fnmatch globbing syntax, or git wildmatch globbing syntax.

The os.globfiles() function uses Win32 wildcard syntax when performing globbing -- it didn't seem to need special in depth documentation, since it's how Windows works and CMD works and etc.

In the TODO.md file you'll notice a todo item regarding supporting fnmatch and wildmatch and recursive globbing.

chrisant996 commented 1 year ago

@sebthom P.S. today I finished implementing an os.globmatch() function, which behaves the same as git in the .gitignore file (e.g. "*/.txt" and so on). Also a path.fnmatch() function is coming which behaves like the Linux function fnmatch(3).

BUT, note: using os.globmatch() to produce matches for the complete, menu-complete, clink-select-complete, etc family of completion commands will not work well (and will be slow and wasteful), because those have no way to show recursive matches. The os.globmatch() function is intended for other custom uses in scripts. For example, a Lua script could define a new luafunc: completion command that presents its own custom behaviors and UI similar to what fzf does, but a match generator can't simply use os.globmatch() and expect completion to work nicely.