Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Parameter naming

Craig Fowler edited this page Jan 27, 2017 · 1 revision

Short and long parameter names

A feature common to command-line applications is to provide both longer (more descriptive) parameter names, as well as shorter one-character aliases for commonly-used parameters.

The convention is that long parameter names are prefixed with two dashes, such as --my-long-param and that short names are prefixed with a single dash, such as -l.

The command-line reader/parser supports both of those syntaxes.

Registering names

When registering parameters, at least one short name or at least one long name must be provided. Beyond this requirement, all further names are optional. Typically, every parameter should have a long name. Parameters which are in common use also have a short name so that they are faster to type.

Multiple names

It is possible to specify multiple long names/short names for the same parameter. Applications do not routinely provide multiple names/aliases for the same parameter, however this functionality is available in order to deal with backwards-compatibility.

Imagine a scenario in which you wish to rename a parameter (perhaps the old name is misleading) but you wish to continue supporting the parameter under the old name for a few application releases.

Clone this wiki locally