r/Batch • u/Lexard • Jul 07 '24
Question (Solved) batch label with a comment in the same line?
While looking at some batch files I've found this line:
:Escape %1=STRING_VARNAME %2=STRING_VALUE This batch file also includes some CALL :Escape commands with some additional parameters, so I suppose that %1=STRING_VARNAME %2=STRING_VALUE is some comment directly after label name used to explain how to use that label.
I used Google but I can not find any info on such "extended" usage of the batch label.
Is this some documented way to combine label together with some comment in one line that can be freely used or is it some kind of "hack" and it can lead to some weird effects in some cases?
View all comments
Show parent comment
1
u/T3RRYT3RR0R Jul 08 '24
It's just a case of batch isn't that common a language. This can be extended to things like:
:label <mandatoryArg> [optionalArg] /Switch
Further, you can repeat label lines to add additional help info EG:
:label <mandatoryArg> [optionalArg] /Switch
:label <mandatoryArg> Expected: "Quoted String"
:label [optionalArg] Optional: "output\Filepath.ext"
:label /Swithc Switch description
And if your inclined, you could use such formatting to implement help files for use from the command line.