Skip to content
Myr

Terminology and links (#1361)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Add separate terminology and cross-reference new documentation * Reword link to extra documentation. Add Terminolgy to README.

authored by John Gee · committed by GitHub · parent 9236449 · Browse files · 3 files+27 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+27 added−22 removed

  • other:+27 added−22 removed

3 files+27 added−22 removed

modified:docs/options-taking-varying-arguments.md+3 added-22 removed
8 unmodified lines
9 - [Alternative: Put options last](#alternative-put-options-last)10 - [Alternative: Use options instead of command-arguments](#alternative-use-options-instead-of-command-arguments)11 - [Combining short options, and options taking arguments](#combining-short-options-and-options-taking-arguments)12 - [Combining short options as if boolean](#combining-short-options-as-if-boolean)13 - [Terminology](#terminology)1314Certain options take a varying number of arguments:1516```js
4 unmodified lines
21```2223This page uses examples with options taking 0 or 1 arguments, but the discussions also apply to variadic options taking more arguments.2425For information about terms used in this document see: [terminology](./terminology.md)2627## Parsing ambiguity2829There is a potential downside to be aware of. If a command has both30command-arguments and options with varying option-arguments, this introduces a parsing ambiguity which may affect the user of your program.
109 unmodified lines
140$ cook -i -t scrambled141technique: scrambled142ingredient: cheese143```144145## Combining short options, and options taking arguments146147Multiple boolean short options can be combined after a single `-`, like `ls -al`. You can also include just148a single short option which might take a value, as any following characters will
49 unmodified lines
198```js199.combineFlagAndOptionalValue(true) // `-v45` is treated like `--vegan=45`, this is the default behaviour200.combineFlagAndOptionalValue(false) // `-vl` is treated like `-v -l`201```200201## Terminology202203_Work in progress: this section may move to the main README, or a page of its own._204205The command line arguments are made up of options, option-arguments, commands, and command-arguments.206207| Term | Explanation |208| --- | --- |209| option | an argument which is a `-` followed by a character, or `--` followed by a word (or hyphenated words), like `-s` or `--short` |210| option-argument| some options can take an argument |211| command | a program or command can have subcommands |212| command-argument | argument for the command (and not an option or option-argument) |213214For example:215216```sh217my-utility command -o --option option-argument command-argument-1 command-argument-2218```219220In other references options are sometimes called flags, and command-arguments are sometimes called positional arguments or operands.
added:docs/terminology.md+18 added
modified:Readme.md+6 added
44 unmodified lines
45 - [Examples](#examples)46 - [Support](#support)47 - [Commander for enterprise](#commander-for-enterprise)4849For information about terms used in this document see: [terminology](./docs/terminology.md)5051## Installation5253```bash54npm install commander
148 unmodified lines
203$ pizza-options --cheese mozzarella204add cheese type mozzarella205```206207For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md).208209### Custom option processing210211You may specify a function to do custom processing of option values. The callback function receives two parameters, the user specified value and the212previous value for the option. It returns the new value for the option.
101 unmodified lines
314Options: { number: [ '1', '2', '3' ], letter: true }315Remaining arguments: [ 'operand' ]316```317318For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md).319320### Version option321322The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits.323
464 unmodified lines