I have been searching for an easy way to parse and interpret Windows command switches. I already know how to capture %*, %1, etc. but I can't seem to see any resource on how to parse compound flags such as in Git: -am
.
I have been trying with something like:
echo(%1|findstr /r /c:"^-.*" >nul && (
echo FOUND
rem any commands can go here
) || (
echo NOT FOUND
rem any commands can go here
)
but to no avail. I thought the command line had easier syntax to deal with them. I want to handle scenarios like -a -m
as well as -am
.
I would also be curious how you code the batch file so that the sequence of the arguments is unrestricted.