Thank you for this tool. The tool requires the -p option, and there can only be one -p option value. I'm confused as to why. Why isn't a list of file names as args to the tool supported? E.g., antlr-format f1.g4 f2.g4 f3.g4 ....). Most shells already provide glob expansion, and Gnu Bash can support globstar expansion with env adjustments. So, antlr-format *.g4 would be expanded as antlr-format f1.g4 f2.g4 f3.g4 .....
Note, in the readme, you don't single quote the arg to the -p option. For Bash and Powershell, the default is to do glob pattern matching unless you set your environment carefully to not do that. So, it may be confusing to some.
I tried this out on a few different environments. See below. Note, globstar pattern expansion in the tool does not work for Windows.
The second file is not formatted, and there is no warning.
Windows
Over on Windows, the pattern expansion does not work.
11/26-15:51:13 ~/issues/g4-3833/abb
$ antlr-format -p '*.g4'
No grammar file found using this pattern: C:\msys64\home\Kenne\issues\g4-3833\abb\*.g4.
11/26-15:51:29 ~/issues/g4-3833/abb
$ antlr-format -p './*.g4'
No grammar file found using this pattern: C:\msys64\home\Kenne\issues\g4-3833\abb\*.g4.
11/26-15:51:36 ~/issues/g4-3833/abb
Note, I am using Msys2 Bash ("Cygwin"-based shell), so single quotes are necessary to avoid Bash glob expansion.
NB: The tool does work on Windows if I skip glob patterns, and simply use the file name explicitly. The tool works fine for either relative or absolute paths, and using either the forward slash or backward slash directory separators.
Powershell operates similarly to Bash. Glob patterns are expanded prior to exec() of the tool. So, one must single quote arguments when calling the tool.
What is the purpose of -p option? Doesn't every shell offer some equivalent to "find"?
Why is the -p option provided? Bash supports glob patterns, and globstar patterns when the env is set for it. (NB: expansion of the glob or globstar patter cannot work if multiple files are discovered, because the -p option only takes one parameter.)
I can also do a find and call the tool for each file:
Thank you for this tool. The tool requires the
-p
option, and there can only be one-p
option value. I'm confused as to why. Why isn't a list of file names as args to the tool supported? E.g.,antlr-format f1.g4 f2.g4 f3.g4 ....
). Most shells already provide glob expansion, and Gnu Bash can support globstar expansion with env adjustments. So,antlr-format *.g4
would be expanded asantlr-format f1.g4 f2.g4 f3.g4 ....
.Note, in the readme, you don't single quote the arg to the
-p
option. For Bash and Powershell, the default is to do glob pattern matching unless you set your environment carefully to not do that. So, it may be confusing to some.I tried this out on a few different environments. See below. Note, globstar pattern expansion in the tool does not work for Windows.
Linux
The tool fine on Linux, e.g.:
But, Bash does glob expansion. So, this does not work:
The second file is not formatted, and there is no warning.
Windows
Over on Windows, the pattern expansion does not work.
Note, I am using Msys2 Bash ("Cygwin"-based shell), so single quotes are necessary to avoid Bash glob expansion.
NB: The tool does work on Windows if I skip glob patterns, and simply use the file name explicitly. The tool works fine for either relative or absolute paths, and using either the forward slash or backward slash directory separators.
Multiple files with one call to antlr-format
If I try to give two files, only the first is formatted.
If I try to give the
-p
option twice, the second-p
option is ignored without warning.It does not matter if I use cmd.exe either.
Powershell on Linux
Powershell operates similarly to Bash. Glob patterns are expanded prior to
exec()
of the tool. So, one must single quote arguments when calling the tool.What is the purpose of -p option? Doesn't every shell offer some equivalent to "find"?
Why is the
-p
option provided? Bash supports glob patterns, and globstar patterns when the env is set for it. (NB: expansion of the glob or globstar patter cannot work if multiple files are discovered, because the-p
option only takes one parameter.)I can also do a
find
and call the tool for each file: