3.1.2.2 Valued Options

Options taking an argument are said to be valued. We need a bit of terminology here: and option’s argument is typically what you provide on the command-line (or elsewhere, see Option Retrieval). An option’s argument is thus a string. An option’s value is what results from the conversion of the option’s argument to the proper type (the same string, a number, whatever).

In Clon, a valued option’s argument can be either mandatory or optional. We know that valued options, just like flags, may be provided in short or long form. When using the long form, the proper way of providing an argument is to append it after an ‘=’ sign, like this: ‘--phone=01020304’. When using the short form, the proper way of providing an argument is to stick it right behind the option’s name, like this: ‘-p01020304’. In both long and short form, we call these arguments “sticky”. All this should look familiar.

When the option’s argument is mandatory, you also have the ability to provide it in the next command-line item instead of sticking it to the option’s name. These arguments are said to be “separated”. Back to the previous example, this means that you can also say ‘--phone 01020304’ or ‘-p 01020304’. Keep in mind that this is not possible when the argument is optional (in the general case, it is not possible to decide whether the next command-line item is an option’s argument, a new option or something else).

There is also another case where you can’t use this alternate syntax, even when the argument is mandatory: that is when the argument itself looks like an option. Clon will think it is, and consequently will also think that the previous one lacks its mandatory argument.

The phone example above would look like this in a standard help string (but see Output):

  -p, --phone=NUM    Set phone number to NUM.

And here is an example illustrating a typical output when the argument is optional:

  -f, --fax[=NUM]    Set fax number to NUM, or same as phone.