Scripts that come with GNU Smalltalk installation use the following code to parse command line arguments:
Smalltalk
arguments: '-h|--help --usage --version'
do: [ :opt :arg |
opt = 'help' ifTrue: [ do something ... ].
opt = 'usage' ifTrue: [ do something ... ].
opt = 'version' ifTrue: [ do something ... ]
]
ifError: [ do something ... ].
]
The thing that troubles me is this:
Smalltalk arguments: '-h|--help --usage --version'
I don't understand what is going on there. I know that:
Smalltalk arguments
returns array of strings passed to the command line, but in this case, it looks like method is being called with argument '-h|--help --usage --version'? I wonder how this string is compared to an arguments array and how command line switches are extracted? A link to a documentation or explanation would be very valuable.