Skip to content

Commit 75a1fcf

Browse files
author
Dean Troyer
committed
Clarification of option name rules
We never specifcally said anywhere that short names are global only and why. Change-Id: Ia2824cb7ebe7c2e1d116c0a9bc7760de24904c61
1 parent b59ade7 commit 75a1fcf

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

doc/source/command-options.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ for defining and using options in all situations. The alternative of only
1414
using it when necessary leads to errors when copy-n-paste is used for a
1515
new command without understanding why or why not that instance is correct.
1616

17+
The :doc:`Human Interface Guide <humaninterfaceguide>`
18+
describes the guildelines for option names and usage. In short:
19+
* All option names shall be GNU-style long names (two leading dashes).
20+
* Some global options may have short nmaes, generally limited to those defined
21+
in support libraries such as ``cliff``.
22+
1723
General Command Options
1824
=======================
1925

doc/source/humaninterfaceguide.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@ Output formats:
183183
* user-friendly tables with headers, etc
184184
* machine-parsable delimited
185185

186-
Notes:
187-
188-
* All long options names shall begin with two dashes ('--') and use a single dash
189-
('-') internally between words (:code:`--like-this`). Underscores ('_') shall not
190-
be used in option names.
191-
* Authentication options conform to the common CLI authentication guidelines in
192-
:doc:`authentication`.
193-
194186
Global Options
195187
~~~~~~~~~~~~~~
196188

@@ -202,6 +194,16 @@ the command-line option takes priority. The environment variable names are deri
202194
from the option name by dropping the leading dashes ('--'), converting each embedded
203195
dash ('-') to an underscore ('_'), and converting to upper case.
204196

197+
* Global options shall always have a long option name, certain common options may
198+
also have short names. Short names should be reserved for global options to limit
199+
the potential for duplication and multiple meanings between commands given the
200+
limited set of available short names.
201+
* All long options names shall begin with two dashes ('--') and use a single dash
202+
('-') internally between words (:code:`--like-this`). Underscores ('_') shall not
203+
be used in option names.
204+
* Authentication options conform to the common CLI authentication guidelines in
205+
:doc:`authentication`.
206+
205207
For example, :code:`--os-username` can be set from the environment via
206208
:code:`OS_USERNAME`.
207209

@@ -245,6 +247,10 @@ Each command may have its own set of options distinct from the global options.
245247
They follow the same style as the global options and always appear between
246248
the command and any positional arguments the command requires.
247249

250+
Command options shall only have long names. The small range of available
251+
short names makes it hard for a single short option name to have a consistent
252+
meaning across multiple commands.
253+
248254
Option Forms
249255
++++++++++++
250256

0 commit comments

Comments
 (0)