woke icon indicating copy to clipboard operation
woke copied to clipboard

Suggestion to improve "glob" expansion in documentation

Open sebastien-rosset opened this issue 3 years ago • 2 comments
trafficstars

Thank you for creating the issue!

  • [x] Yes, I've searched similar issues on GitHub and didn't find any.
  • [x] Yes, I've included all information below (version, config, etc). This is a doc-only issue.

In the documentation at https://github.com/get-woke/woke/blame/main/docs/usage.md#L30-L33:

To change this, supply a space-separated list of globs as the first argument.

I suggest removing "as the first argument". Since the patterns are space-separated, they are interpreted by the shell as multiple arguments. woke parses all arguments, not just the first argument.

This can be something like **/*.go, or a space-separated list of filenames.

It would be worth clarifying the glob expansion is performed by the shell. woke itself is not doing any globbing expansion. In particular, given the ambiguity of the documentation, one might expect the pattern below to be expanded by woke, but it's not.

woke '**/*.go'

This is a bit confusing because different shells have different globbing behaviors. Some shells do not support the double star glob pattern. In bash >= 4, the double star is used as an extended file match globbing operator, meaning it matches filenames and directories recursively. However, the exact behavior depends on the globstar value:

shopt -s globstar ; woke **/*.go shopt -u globstar ; woke **/*.go

How about adding support for glob expansion in woke? This would provide consistent and deterministic results that do not depend on the shell glob expansion.

Please include the following information:

Version of woke
$ woke --version
# paste output here
woke version 0.18.2
Config file
$ cat .woke.yml
# paste output here
N/A
Go environment
$ go version && go env
# paste output here
N/A
Verbose output of running
$ woke --debug
# paste output here
N/A

sebastien-rosset avatar Jun 28 '22 15:06 sebastien-rosset

👋 Thanks for submitting your first issue!

Please be sure to read and follow our Code of Conduct and Contributing guide.

⭐️ Is your org or open source project using woke? If so, we'd love for you to be included in the 'Who uses woke' list at https://github.com/get-woke/woke/blob/main/docs/about.md#who-uses-woke.

github-actions[bot] avatar Jun 28 '22 15:06 github-actions[bot]

What do you think about supporting ** glob expansion using one of the libraries listed here: https://www.client9.com/golang-globs-and-the-double-star-glob-operator/?

  1. mattn/go-zglob looks very optimized for filewalking
  2. bmatcuk/doublestar appears to be the most mature
  3. godo/glob.go is an implementation embedded inside godo

sebastien-rosset avatar Jun 28 '22 19:06 sebastien-rosset