Skip to content

Commit

Permalink
docs: explain kebab-case options
Browse files Browse the repository at this point in the history
Related: #61
  • Loading branch information
egoist committed Jan 13, 2020
1 parent cb367c9 commit 172f4cb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Simple Parsing](#simple-parsing)
- [Display Help Message and Version](#display-help-message-and-version)
- [Command-specific Options](#command-specific-options)
- [Dash in option names](#dash-in-option-names)
- [Brackets](#brackets)
- [Variadic Arguments](#variadic-arguments)
- [Dot-nested Options](#dot-nested-options)
Expand Down Expand Up @@ -130,6 +131,21 @@ A command's options are validated when the command is used. Any unknown options

<img alt="command options" width="500" src="https://user-images.githubusercontent.com/8784712/49065552-49dc8500-f259-11e8-9c7b-a7c32d70920e.png">

### Dash in option names

Options in kebab-case should be referenced in camelCase in your code:

```js
cli
.command('dev', 'Start dev server')
.option('--clear-screen', 'Clearn screen')
.action(options => {
console.log(options.clearScreen)
})
```

In fact `--clear-screen` and `--clearScreen` are both mapped to `options.clearScreen`.

### Brackets

When using brackets in command name, angled brackets indicate required command arguments, while square bracket indicate optional arguments.
Expand Down

0 comments on commit 172f4cb

Please sign in to comment.