From df03ab48a585cb3e41a6cccbe2b42cefdf772496 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Tue, 16 May 2023 15:49:32 -0700 Subject: [PATCH] chore: format all possible files with prettier --- .github/workflows/ci.yaml | 2 +- .github/workflows/release-please.yml | 6 +- .nycrc | 10 +- .prettierrc.cjs | 4 +- CHANGELOG.md | 279 +++---- CODE_OF_CONDUCT.md | 20 +- README.md | 123 +-- contributing.md | 12 +- docs/CHANGELOG-historical.md | 909 ++++++++++------------ docs/advanced.md | 350 +++++---- docs/api.md | 947 +++++++++++------------ docs/browser.md | 22 +- docs/bundling.md | 80 +- docs/examples.md | 180 ++--- docs/tricks.md | 19 +- docs/typescript.md | 20 +- example/bool.js | 6 +- example/boolean_double.js | 11 +- example/boolean_single.js | 10 +- example/cmds/init.js | 14 +- example/cmds/remote.js | 10 +- example/cmds/remote_cmds/add.js | 10 +- example/cmds/remote_cmds/prune.js | 13 +- example/command_hierarchy.js | 3 +- example/complex.js | 15 +- example/count.js | 23 +- example/default_hash.js | 9 +- example/default_singles.js | 6 +- example/demand_count.js | 6 +- example/divide.js | 5 +- example/help.js | 23 +- example/implies.js | 7 +- example/implies_hash.js | 21 +- example/line_count.js | 15 +- example/line_count_options.js | 33 +- example/line_count_wrap.js | 34 +- example/strict.js | 26 +- example/string.js | 7 +- example/usage-options.js | 25 +- example/xup.js | 4 +- example/yargs.html | 38 +- lib/platform-shims/esm.mjs | 63 +- locales/cs.json | 2 +- locales/en.json | 2 +- locales/fi.json | 2 +- locales/fr.json | 2 +- locales/hi.json | 2 +- locales/id.json | 3 +- locales/ja.json | 2 +- locales/ko.json | 2 +- locales/pirate.json | 2 +- locales/pt.json | 2 +- locales/pt_BR.json | 2 +- locales/uk_UA.json | 2 +- locales/uz.json | 101 ++- locales/zh_CN.json | 2 +- locales/zh_TW.json | 100 +-- renovate.json | 4 +- test/fixtures/config.json | 10 +- test/fixtures/extends/circular_1.json | 2 +- test/fixtures/extends/circular_2.json | 2 +- test/fixtures/extends/config_1.json | 2 +- test/fixtures/extends/config_2.json | 2 +- test/fixtures/extends/config_deep.json | 2 +- test/fixtures/extends/config_deep_2.json | 2 +- test/usage.cjs | 3 +- test/yargs.cjs | 15 +- tsconfig.json | 16 +- tsconfig.test.json | 9 +- 69 files changed, 1808 insertions(+), 1909 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c80a0ea91..9862d759a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,7 +3,7 @@ on: branches: - main pull_request: - types: [ assigned, opened, synchronize, reopened, labeled ] + types: [assigned, opened, synchronize, reopened, labeled] name: ci permissions: contents: read # to fetch code (actions/checkout) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index ce806bd7d..69f0f1407 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -1,7 +1,7 @@ on: - push: - branches: - - main + push: + branches: + - main name: release-please permissions: {} jobs: diff --git a/.nycrc b/.nycrc index d4b247808..db2d48d4c 100644 --- a/.nycrc +++ b/.nycrc @@ -1,13 +1,7 @@ { - "exclude": [ - "build/test/**", - "test/**" - ], + "exclude": ["build/test/**", "test/**"], "exclude-after-remap": true, - "reporter": [ - "html", - "text" - ], + "reporter": ["html", "text"], "lines": 100, "branches": "96", "statements": "100" diff --git a/.prettierrc.cjs b/.prettierrc.cjs index ff1548339..c5166c2ae 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -1,3 +1,3 @@ module.exports = { - ...require('gts/.prettierrc.json') -} + ...require('gts/.prettierrc.json'), +}; diff --git a/CHANGELOG.md b/CHANGELOG.md index 56c162e48..79cc5de6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,327 +4,290 @@ All notable changes to this project will be documented in this file. See [standa ## [17.7.2](https://github.com/yargs/yargs/compare/v17.7.1...v17.7.2) (2023-04-27) - ### Bug Fixes -* do not crash completion when having negated options ([#2322](https://github.com/yargs/yargs/issues/2322)) ([7f42848](https://github.com/yargs/yargs/commit/7f428485e75e9b1b0db1320216d1c31469770563)) +- do not crash completion when having negated options ([#2322](https://github.com/yargs/yargs/issues/2322)) ([7f42848](https://github.com/yargs/yargs/commit/7f428485e75e9b1b0db1320216d1c31469770563)) ## [17.7.1](https://github.com/yargs/yargs/compare/v17.7.0...v17.7.1) (2023-02-21) - ### Bug Fixes -* address display bug with default sub-commands ([#2303](https://github.com/yargs/yargs/issues/2303)) ([9aa2490](https://github.com/yargs/yargs/commit/9aa24908ae4e857161d5084613a402f9dc4895a7)) +- address display bug with default sub-commands ([#2303](https://github.com/yargs/yargs/issues/2303)) ([9aa2490](https://github.com/yargs/yargs/commit/9aa24908ae4e857161d5084613a402f9dc4895a7)) ## [17.7.0](https://github.com/yargs/yargs/compare/v17.6.2...v17.7.0) (2023-02-13) - ### Features -* add method to hide option extras ([#2156](https://github.com/yargs/yargs/issues/2156)) ([2c144c4](https://github.com/yargs/yargs/commit/2c144c4ea534646df26d6177f73ce917105c6c09)) -* convert line break to whitespace for the description of the option ([#2271](https://github.com/yargs/yargs/issues/2271)) ([4cb41dc](https://github.com/yargs/yargs/commit/4cb41dc80aaa730a2abd15bd3118ecd9f4ebe876)) - +- add method to hide option extras ([#2156](https://github.com/yargs/yargs/issues/2156)) ([2c144c4](https://github.com/yargs/yargs/commit/2c144c4ea534646df26d6177f73ce917105c6c09)) +- convert line break to whitespace for the description of the option ([#2271](https://github.com/yargs/yargs/issues/2271)) ([4cb41dc](https://github.com/yargs/yargs/commit/4cb41dc80aaa730a2abd15bd3118ecd9f4ebe876)) ### Bug Fixes -* copy the description of the option to its alias in completion ([#2269](https://github.com/yargs/yargs/issues/2269)) ([f37ee6f](https://github.com/yargs/yargs/commit/f37ee6f7da386a1244bf0a0c21b9572f2bb3131b)) +- copy the description of the option to its alias in completion ([#2269](https://github.com/yargs/yargs/issues/2269)) ([f37ee6f](https://github.com/yargs/yargs/commit/f37ee6f7da386a1244bf0a0c21b9572f2bb3131b)) ## [17.6.2](https://github.com/yargs/yargs/compare/v17.6.1...v17.6.2) (2022-11-03) - ### Bug Fixes -* **deps:** update dependency yargs-parser to v21.1.1 ([#2231](https://github.com/yargs/yargs/issues/2231)) ([75b4d52](https://github.com/yargs/yargs/commit/75b4d5222f8f0152790b9ca0718fa5314c9a1c6b)) -* **lang:** typo in Finnish unknown argument singular form ([#2222](https://github.com/yargs/yargs/issues/2222)) ([a6dfd0a](https://github.com/yargs/yargs/commit/a6dfd0a8f7f2c58a2e8b7dde0142cc1a12c4e027)) +- **deps:** update dependency yargs-parser to v21.1.1 ([#2231](https://github.com/yargs/yargs/issues/2231)) ([75b4d52](https://github.com/yargs/yargs/commit/75b4d5222f8f0152790b9ca0718fa5314c9a1c6b)) +- **lang:** typo in Finnish unknown argument singular form ([#2222](https://github.com/yargs/yargs/issues/2222)) ([a6dfd0a](https://github.com/yargs/yargs/commit/a6dfd0a8f7f2c58a2e8b7dde0142cc1a12c4e027)) ## [17.6.1](https://github.com/yargs/yargs/compare/v17.6.0...v17.6.1) (2022-11-02) - ### Bug Fixes -* **lang:** fix "Not enough non-option arguments" message for the Czech language ([#2242](https://github.com/yargs/yargs/issues/2242)) ([3987b13](https://github.com/yargs/yargs/commit/3987b13e31f669d79836cc6ed84105e9be0f9482)) +- **lang:** fix "Not enough non-option arguments" message for the Czech language ([#2242](https://github.com/yargs/yargs/issues/2242)) ([3987b13](https://github.com/yargs/yargs/commit/3987b13e31f669d79836cc6ed84105e9be0f9482)) ## [17.6.0](https://github.com/yargs/yargs/compare/v17.5.1...v17.6.0) (2022-10-01) - ### Features -* **lang:** Czech locale ([#2220](https://github.com/yargs/yargs/issues/2220)) ([5895cf1](https://github.com/yargs/yargs/commit/5895cf1ba1dcd5158d284d0c589f5f0caff8b739)) -* **usage:** add YARGS_DISABLE_WRAP env variable to disable wrap ([#2210](https://github.com/yargs/yargs/issues/2210)) ([b680ace](https://github.com/yargs/yargs/commit/b680ace2994dcf14d1a1a928aefd3fe8006b2198)) - +- **lang:** Czech locale ([#2220](https://github.com/yargs/yargs/issues/2220)) ([5895cf1](https://github.com/yargs/yargs/commit/5895cf1ba1dcd5158d284d0c589f5f0caff8b739)) +- **usage:** add YARGS_DISABLE_WRAP env variable to disable wrap ([#2210](https://github.com/yargs/yargs/issues/2210)) ([b680ace](https://github.com/yargs/yargs/commit/b680ace2994dcf14d1a1a928aefd3fe8006b2198)) ### Bug Fixes -* **deno:** use 'globalThis' instead of 'window' ([#2186](https://github.com/yargs/yargs/issues/2186)) ([#2215](https://github.com/yargs/yargs/issues/2215)) ([561fc7a](https://github.com/yargs/yargs/commit/561fc7a787228b226e0ba76ab674456cbd30cd37)) -* **deps:** cliui with forced strip-ansi update ([#2241](https://github.com/yargs/yargs/issues/2241)) ([38e8df1](https://github.com/yargs/yargs/commit/38e8df10f0f020ae794329610354521f8458fc41)) -* dont clobber description for multiple option calls ([#2171](https://github.com/yargs/yargs/issues/2171)) ([f91d9b3](https://github.com/yargs/yargs/commit/f91d9b334ad9cfce79a89c08ff210c622b7c528f)) -* **typescript:** address warning with objectKeys ([394f5f8](https://github.com/yargs/yargs/commit/394f5f86d15a9bb319276518d36cb560d7cb6322)) +- **deno:** use 'globalThis' instead of 'window' ([#2186](https://github.com/yargs/yargs/issues/2186)) ([#2215](https://github.com/yargs/yargs/issues/2215)) ([561fc7a](https://github.com/yargs/yargs/commit/561fc7a787228b226e0ba76ab674456cbd30cd37)) +- **deps:** cliui with forced strip-ansi update ([#2241](https://github.com/yargs/yargs/issues/2241)) ([38e8df1](https://github.com/yargs/yargs/commit/38e8df10f0f020ae794329610354521f8458fc41)) +- dont clobber description for multiple option calls ([#2171](https://github.com/yargs/yargs/issues/2171)) ([f91d9b3](https://github.com/yargs/yargs/commit/f91d9b334ad9cfce79a89c08ff210c622b7c528f)) +- **typescript:** address warning with objectKeys ([394f5f8](https://github.com/yargs/yargs/commit/394f5f86d15a9bb319276518d36cb560d7cb6322)) ### [17.5.1](https://github.com/yargs/yargs/compare/v17.5.0...v17.5.1) (2022-05-16) - ### Bug Fixes -* add missing entries to published files ([#2185](https://github.com/yargs/yargs/issues/2185)) ([5685382](https://github.com/yargs/yargs/commit/5685382d18dc05f2ec66098d90ab16f31b622753)) -* address bug when strict and async middleware used together ([#2164](https://github.com/yargs/yargs/issues/2164)) ([cbc2eb7](https://github.com/yargs/yargs/commit/cbc2eb726efc1d688ad484e8cbe4d233b212a046)) -* **completion:** correct zsh installation instructions ([22e9af2](https://github.com/yargs/yargs/commit/22e9af28bb7a7101aeeac80b5bfd0c18f7e6226f)) -* handle multiple node_modules folders determining mainFilename for ESM ([#2123](https://github.com/yargs/yargs/issues/2123)) ([e0823dd](https://github.com/yargs/yargs/commit/e0823dd7e6ced7eaf1d7d1e67f77374f4ef5cbce)) -* **lang:** add missing terms to Russian translation ([#2181](https://github.com/yargs/yargs/issues/2181)) ([1c331f2](https://github.com/yargs/yargs/commit/1c331f22c71496e3d50cf103a1b21f4a05d97aac)) -* prevent infinite loop with empty locale ([#2179](https://github.com/yargs/yargs/issues/2179)) ([b672e70](https://github.com/yargs/yargs/commit/b672e709e4fc45f50d77f54e42025a5fa7c66a42)) -* veriadic arguments override array provided in config (the same as multiple dash arguments). ([4dac5b8](https://github.com/yargs/yargs/commit/4dac5b8c2f03488c31d40f075075d2ac43134412)) +- add missing entries to published files ([#2185](https://github.com/yargs/yargs/issues/2185)) ([5685382](https://github.com/yargs/yargs/commit/5685382d18dc05f2ec66098d90ab16f31b622753)) +- address bug when strict and async middleware used together ([#2164](https://github.com/yargs/yargs/issues/2164)) ([cbc2eb7](https://github.com/yargs/yargs/commit/cbc2eb726efc1d688ad484e8cbe4d233b212a046)) +- **completion:** correct zsh installation instructions ([22e9af2](https://github.com/yargs/yargs/commit/22e9af28bb7a7101aeeac80b5bfd0c18f7e6226f)) +- handle multiple node_modules folders determining mainFilename for ESM ([#2123](https://github.com/yargs/yargs/issues/2123)) ([e0823dd](https://github.com/yargs/yargs/commit/e0823dd7e6ced7eaf1d7d1e67f77374f4ef5cbce)) +- **lang:** add missing terms to Russian translation ([#2181](https://github.com/yargs/yargs/issues/2181)) ([1c331f2](https://github.com/yargs/yargs/commit/1c331f22c71496e3d50cf103a1b21f4a05d97aac)) +- prevent infinite loop with empty locale ([#2179](https://github.com/yargs/yargs/issues/2179)) ([b672e70](https://github.com/yargs/yargs/commit/b672e709e4fc45f50d77f54e42025a5fa7c66a42)) +- veriadic arguments override array provided in config (the same as multiple dash arguments). ([4dac5b8](https://github.com/yargs/yargs/commit/4dac5b8c2f03488c31d40f075075d2ac43134412)) ## [17.5.0](https://github.com/yargs/yargs/compare/v17.4.1...v17.5.0) (2022-05-11) - ### Features -* add browser.d.ts and check for existence of Error.captureStackTrace() ([#2144](https://github.com/yargs/yargs/issues/2144)) ([6192990](https://github.com/yargs/yargs/commit/6192990509cf793c4b10b88884d626893dee89df)) - +- add browser.d.ts and check for existence of Error.captureStackTrace() ([#2144](https://github.com/yargs/yargs/issues/2144)) ([6192990](https://github.com/yargs/yargs/commit/6192990509cf793c4b10b88884d626893dee89df)) ### Bug Fixes -* **completion:** support for default flags ([db35423](https://github.com/yargs/yargs/commit/db354232705623bbcd8fad362f6a4d6d59650be5)) -* import yargs/yargs in esm projects ([#2151](https://github.com/yargs/yargs/issues/2151)) ([95aed1c](https://github.com/yargs/yargs/commit/95aed1c175ec82e585003883bda1b6b75d5493ce)) +- **completion:** support for default flags ([db35423](https://github.com/yargs/yargs/commit/db354232705623bbcd8fad362f6a4d6d59650be5)) +- import yargs/yargs in esm projects ([#2151](https://github.com/yargs/yargs/issues/2151)) ([95aed1c](https://github.com/yargs/yargs/commit/95aed1c175ec82e585003883bda1b6b75d5493ce)) ### [17.4.1](https://github.com/yargs/yargs/compare/v17.4.0...v17.4.1) (2022-04-09) - ### Bug Fixes -* coerce pollutes argv ([#2161](https://github.com/yargs/yargs/issues/2161)) ([2d1136d](https://github.com/yargs/yargs/commit/2d1136d303ea805685a973ded62f52efd49b78b9)) -* **completion:** don't show positional args choices with option choices ([#2148](https://github.com/yargs/yargs/issues/2148)) ([b58b5bc](https://github.com/yargs/yargs/commit/b58b5bc2cda7fc15acf559ae4a6a0eda0be06044)) -* hide hidden options from completion ([#2143](https://github.com/yargs/yargs/issues/2143)) ([e086dfa](https://github.com/yargs/yargs/commit/e086dfad7ff11956b1e8779c00cf2351a4cc3b03)), closes [#2142](https://github.com/yargs/yargs/issues/2142) -* show message when showHelpOnFail is chained globally ([#2154](https://github.com/yargs/yargs/issues/2154)) ([ad9fcac](https://github.com/yargs/yargs/commit/ad9fcacb001a7eb842924408f3a06865a7c7a3b6)) +- coerce pollutes argv ([#2161](https://github.com/yargs/yargs/issues/2161)) ([2d1136d](https://github.com/yargs/yargs/commit/2d1136d303ea805685a973ded62f52efd49b78b9)) +- **completion:** don't show positional args choices with option choices ([#2148](https://github.com/yargs/yargs/issues/2148)) ([b58b5bc](https://github.com/yargs/yargs/commit/b58b5bc2cda7fc15acf559ae4a6a0eda0be06044)) +- hide hidden options from completion ([#2143](https://github.com/yargs/yargs/issues/2143)) ([e086dfa](https://github.com/yargs/yargs/commit/e086dfad7ff11956b1e8779c00cf2351a4cc3b03)), closes [#2142](https://github.com/yargs/yargs/issues/2142) +- show message when showHelpOnFail is chained globally ([#2154](https://github.com/yargs/yargs/issues/2154)) ([ad9fcac](https://github.com/yargs/yargs/commit/ad9fcacb001a7eb842924408f3a06865a7c7a3b6)) ## [17.4.0](https://github.com/yargs/yargs/compare/v17.3.1...v17.4.0) (2022-03-19) - ### Features -* **completion:** choices will now work for all possible aliases of an option and not just the default long option ([30edd50](https://github.com/yargs/yargs/commit/30edd5067111b2b59387dcc47f4e7af93b9054f3)) -* **completion:** positional arguments completion ([#2090](https://github.com/yargs/yargs/issues/2090)) ([00e4ebb](https://github.com/yargs/yargs/commit/00e4ebbe3acd438e73fdb101e75b4f879eb6d345)) - +- **completion:** choices will now work for all possible aliases of an option and not just the default long option ([30edd50](https://github.com/yargs/yargs/commit/30edd5067111b2b59387dcc47f4e7af93b9054f3)) +- **completion:** positional arguments completion ([#2090](https://github.com/yargs/yargs/issues/2090)) ([00e4ebb](https://github.com/yargs/yargs/commit/00e4ebbe3acd438e73fdb101e75b4f879eb6d345)) ### Bug Fixes -* **completion:** changed the check for option arguments to match options that begin with '-', instead of '--', to include short options ([30edd50](https://github.com/yargs/yargs/commit/30edd5067111b2b59387dcc47f4e7af93b9054f3)) -* **completion:** fix for completions that contain non-leading hyphens ([30edd50](https://github.com/yargs/yargs/commit/30edd5067111b2b59387dcc47f4e7af93b9054f3)) -* failed command usage string is missing arg descriptions and optional args ([#2105](https://github.com/yargs/yargs/issues/2105)) ([d6e342d](https://github.com/yargs/yargs/commit/d6e342d8ef2c488f438c32770ba2209cf8223342)) -* wrap unknown args in quotes ([#2092](https://github.com/yargs/yargs/issues/2092)) ([6a29778](https://github.com/yargs/yargs/commit/6a2977867bd58dbd8bb550f7b0b4c4c298835597)) +- **completion:** changed the check for option arguments to match options that begin with '-', instead of '--', to include short options ([30edd50](https://github.com/yargs/yargs/commit/30edd5067111b2b59387dcc47f4e7af93b9054f3)) +- **completion:** fix for completions that contain non-leading hyphens ([30edd50](https://github.com/yargs/yargs/commit/30edd5067111b2b59387dcc47f4e7af93b9054f3)) +- failed command usage string is missing arg descriptions and optional args ([#2105](https://github.com/yargs/yargs/issues/2105)) ([d6e342d](https://github.com/yargs/yargs/commit/d6e342d8ef2c488f438c32770ba2209cf8223342)) +- wrap unknown args in quotes ([#2092](https://github.com/yargs/yargs/issues/2092)) ([6a29778](https://github.com/yargs/yargs/commit/6a2977867bd58dbd8bb550f7b0b4c4c298835597)) ### [17.3.1](https://github.com/yargs/yargs/compare/v17.3.0...v17.3.1) (2021-12-23) - ### Bug Fixes -* **translations:** correct Korean translation ([#2095](https://github.com/yargs/yargs/issues/2095)) ([c7c2b9e](https://github.com/yargs/yargs/commit/c7c2b9eb340754ddac7bdd1687c7951332c5ebba)) +- **translations:** correct Korean translation ([#2095](https://github.com/yargs/yargs/issues/2095)) ([c7c2b9e](https://github.com/yargs/yargs/commit/c7c2b9eb340754ddac7bdd1687c7951332c5ebba)) ## [17.3.0](https://github.com/yargs/yargs/compare/v17.2.1...v17.3.0) (2021-11-30) - ### Features -* fallback to default bash completion ([74c0ba5](https://github.com/yargs/yargs/commit/74c0ba5cfcc59afa5538de821fad70e1a76a354e)) - +- fallback to default bash completion ([74c0ba5](https://github.com/yargs/yargs/commit/74c0ba5cfcc59afa5538de821fad70e1a76a354e)) ### Bug Fixes -* avoid legacy accessors ([#2013](https://github.com/yargs/yargs/issues/2013)) ([adb0d11](https://github.com/yargs/yargs/commit/adb0d11e02c613af3d9427b3028cc192703a3869)) -* **deps:** update dependency yargs-parser to v21 ([#2063](https://github.com/yargs/yargs/issues/2063)) ([76c1951](https://github.com/yargs/yargs/commit/76c19518d74ca94c0edcd450e5c0ef9efeee369d)) -* don't fail if "fileURLToPath(import.meta.url)" throws ([3a44796](https://github.com/yargs/yargs/commit/3a44796c84e3cb60769841d5883448a396227ade)) -* re-add options to check callback ([#2079](https://github.com/yargs/yargs/issues/2079)) ([e75319d](https://github.com/yargs/yargs/commit/e75319d99142a048b0abe9856499730fd4bc004c)) +- avoid legacy accessors ([#2013](https://github.com/yargs/yargs/issues/2013)) ([adb0d11](https://github.com/yargs/yargs/commit/adb0d11e02c613af3d9427b3028cc192703a3869)) +- **deps:** update dependency yargs-parser to v21 ([#2063](https://github.com/yargs/yargs/issues/2063)) ([76c1951](https://github.com/yargs/yargs/commit/76c19518d74ca94c0edcd450e5c0ef9efeee369d)) +- don't fail if "fileURLToPath(import.meta.url)" throws ([3a44796](https://github.com/yargs/yargs/commit/3a44796c84e3cb60769841d5883448a396227ade)) +- re-add options to check callback ([#2079](https://github.com/yargs/yargs/issues/2079)) ([e75319d](https://github.com/yargs/yargs/commit/e75319d99142a048b0abe9856499730fd4bc004c)) ### [17.2.1](https://www.github.com/yargs/yargs/compare/v17.2.0...v17.2.1) (2021-09-25) - ### Bug Fixes -* **docs:** stop advertising .argv property ([#2036](https://www.github.com/yargs/yargs/issues/2036)) ([4f5ecc1](https://www.github.com/yargs/yargs/commit/4f5ecc1427ed6c83f23ea90ee6da75ce0c332f7a)), closes [#2035](https://www.github.com/yargs/yargs/issues/2035) +- **docs:** stop advertising .argv property ([#2036](https://www.github.com/yargs/yargs/issues/2036)) ([4f5ecc1](https://www.github.com/yargs/yargs/commit/4f5ecc1427ed6c83f23ea90ee6da75ce0c332f7a)), closes [#2035](https://www.github.com/yargs/yargs/issues/2035) ## [17.2.0](https://www.github.com/yargs/yargs/compare/v17.1.1...v17.2.0) (2021-09-23) - ### Features -* autocomplete choices for options ([#2018](https://www.github.com/yargs/yargs/issues/2018)) ([01b2c6a](https://www.github.com/yargs/yargs/commit/01b2c6a99167d826d3d1e6f6b94f18382a17d47e)) -* **locales:** Added Uzbek translation ([#2024](https://www.github.com/yargs/yargs/issues/2024)) ([ee047b9](https://www.github.com/yargs/yargs/commit/ee047b9cd6260ce90d845e7e687228e617c8a30d)) - +- autocomplete choices for options ([#2018](https://www.github.com/yargs/yargs/issues/2018)) ([01b2c6a](https://www.github.com/yargs/yargs/commit/01b2c6a99167d826d3d1e6f6b94f18382a17d47e)) +- **locales:** Added Uzbek translation ([#2024](https://www.github.com/yargs/yargs/issues/2024)) ([ee047b9](https://www.github.com/yargs/yargs/commit/ee047b9cd6260ce90d845e7e687228e617c8a30d)) ### Bug Fixes -* boolean option should work with strict ([#1996](https://www.github.com/yargs/yargs/issues/1996)) ([e9379e2](https://www.github.com/yargs/yargs/commit/e9379e27d49820f4db842f22cda6410bbe2bff10)) -* cast error types as TypeScript 4.4 infers them as unknown instead of any ([#2016](https://www.github.com/yargs/yargs/issues/2016)) ([01b2c6a](https://www.github.com/yargs/yargs/commit/01b2c6a99167d826d3d1e6f6b94f18382a17d47e)) -* conflicts and strip-dashed ([#1998](https://www.github.com/yargs/yargs/issues/1998)) ([59a86fb](https://www.github.com/yargs/yargs/commit/59a86fb83cfeb8533c6dd446c73cf4166cc455f2)) -* emit warning on version name collision ([#1986](https://www.github.com/yargs/yargs/issues/1986)) ([d0e8292](https://www.github.com/yargs/yargs/commit/d0e829239580bd44873bbde65de2ed7671aa2ab0)) -* help command spacing when scriptName is empty ([#1994](https://www.github.com/yargs/yargs/issues/1994)) ([d33e997](https://www.github.com/yargs/yargs/commit/d33e9972291406490cd8fdad0b3589be234e0f12)) +- boolean option should work with strict ([#1996](https://www.github.com/yargs/yargs/issues/1996)) ([e9379e2](https://www.github.com/yargs/yargs/commit/e9379e27d49820f4db842f22cda6410bbe2bff10)) +- cast error types as TypeScript 4.4 infers them as unknown instead of any ([#2016](https://www.github.com/yargs/yargs/issues/2016)) ([01b2c6a](https://www.github.com/yargs/yargs/commit/01b2c6a99167d826d3d1e6f6b94f18382a17d47e)) +- conflicts and strip-dashed ([#1998](https://www.github.com/yargs/yargs/issues/1998)) ([59a86fb](https://www.github.com/yargs/yargs/commit/59a86fb83cfeb8533c6dd446c73cf4166cc455f2)) +- emit warning on version name collision ([#1986](https://www.github.com/yargs/yargs/issues/1986)) ([d0e8292](https://www.github.com/yargs/yargs/commit/d0e829239580bd44873bbde65de2ed7671aa2ab0)) +- help command spacing when scriptName is empty ([#1994](https://www.github.com/yargs/yargs/issues/1994)) ([d33e997](https://www.github.com/yargs/yargs/commit/d33e9972291406490cd8fdad0b3589be234e0f12)) ### [17.1.1](https://www.github.com/yargs/yargs/compare/v17.1.0...v17.1.1) (2021-08-13) - ### Bug Fixes -* positional array defaults should not be combined with provided values ([#2006](https://www.github.com/yargs/yargs/issues/2006)) ([832222d](https://www.github.com/yargs/yargs/commit/832222d7777da49e5c9da6c5801c2dd90d7fa6a2)) +- positional array defaults should not be combined with provided values ([#2006](https://www.github.com/yargs/yargs/issues/2006)) ([832222d](https://www.github.com/yargs/yargs/commit/832222d7777da49e5c9da6c5801c2dd90d7fa6a2)) ## [17.1.0](https://www.github.com/yargs/yargs/compare/v17.0.1...v17.1.0) (2021-08-04) - ### Features -* update Levenshtein to Damerau-Levenshtein ([#1973](https://www.github.com/yargs/yargs/issues/1973)) ([d2c121b](https://www.github.com/yargs/yargs/commit/d2c121b00f2e1eb2ea8cc3a23a5039b3a4425bea)) - +- update Levenshtein to Damerau-Levenshtein ([#1973](https://www.github.com/yargs/yargs/issues/1973)) ([d2c121b](https://www.github.com/yargs/yargs/commit/d2c121b00f2e1eb2ea8cc3a23a5039b3a4425bea)) ### Bug Fixes -* coerce middleware should be applied once ([#1978](https://www.github.com/yargs/yargs/issues/1978)) ([14bd6be](https://www.github.com/yargs/yargs/commit/14bd6bebc3027ae929106b20dd198b9dccdeec31)) -* implies should not fail when implied key's value is 0, false or empty string ([#1985](https://www.github.com/yargs/yargs/issues/1985)) ([8010472](https://www.github.com/yargs/yargs/commit/80104727d5f2ec4c5b491c1bdec4c94b2db95d9c)) -* positionals should not overwrite options ([#1992](https://www.github.com/yargs/yargs/issues/1992)) ([9d84309](https://www.github.com/yargs/yargs/commit/9d84309e53ce1d30b1c61035ed5c78827a89df86)) -* strict should fail unknown arguments ([#1977](https://www.github.com/yargs/yargs/issues/1977)) ([c804f0d](https://www.github.com/yargs/yargs/commit/c804f0db78e56b44341cc7a91878c27b1b68b9f2)) -* wrap(null) no longer causes strange indentation behavior ([#1988](https://www.github.com/yargs/yargs/issues/1988)) ([e1871aa](https://www.github.com/yargs/yargs/commit/e1871aa792de219b221179417d410931af70d405)) +- coerce middleware should be applied once ([#1978](https://www.github.com/yargs/yargs/issues/1978)) ([14bd6be](https://www.github.com/yargs/yargs/commit/14bd6bebc3027ae929106b20dd198b9dccdeec31)) +- implies should not fail when implied key's value is 0, false or empty string ([#1985](https://www.github.com/yargs/yargs/issues/1985)) ([8010472](https://www.github.com/yargs/yargs/commit/80104727d5f2ec4c5b491c1bdec4c94b2db95d9c)) +- positionals should not overwrite options ([#1992](https://www.github.com/yargs/yargs/issues/1992)) ([9d84309](https://www.github.com/yargs/yargs/commit/9d84309e53ce1d30b1c61035ed5c78827a89df86)) +- strict should fail unknown arguments ([#1977](https://www.github.com/yargs/yargs/issues/1977)) ([c804f0d](https://www.github.com/yargs/yargs/commit/c804f0db78e56b44341cc7a91878c27b1b68b9f2)) +- wrap(null) no longer causes strange indentation behavior ([#1988](https://www.github.com/yargs/yargs/issues/1988)) ([e1871aa](https://www.github.com/yargs/yargs/commit/e1871aa792de219b221179417d410931af70d405)) ### [17.0.1](https://www.github.com/yargs/yargs/compare/v17.0.0...v17.0.1) (2021-05-03) - ### Bug Fixes -* **build:** Node 12 is now minimum version ([#1936](https://www.github.com/yargs/yargs/issues/1936)) ([0924566](https://www.github.com/yargs/yargs/commit/09245666e57facb140e0b45a9e45ca704883e5dd)) +- **build:** Node 12 is now minimum version ([#1936](https://www.github.com/yargs/yargs/issues/1936)) ([0924566](https://www.github.com/yargs/yargs/commit/09245666e57facb140e0b45a9e45ca704883e5dd)) ## [17.0.0](https://www.github.com/yargs/yargs/compare/v16.2.0...v17.0.0) (2021-05-02) - ### ⚠ BREAKING CHANGES -* **node:** drop Node 10 (#1919) -* implicitly private methods are now actually private -* deprecated reset() method is now private (call yargs() instead). -* **yargs-factory:** refactor yargs-factory to use class (#1895) -* .positional() now allowed at root level of yargs. -* **coerce:** coerce is now applied before validation. -* **async:** yargs now returns a promise if async or check are asynchronous. -* **middleware:** global middleware now applied when no command is configured. -* #1823 contains the following breaking API changes: - * now returns a promise if handler is async. - * onFinishCommand removed, in favor of being able to await promise. - * getCompletion now invokes callback with err and `completions, returns promise of completions. +- **node:** drop Node 10 (#1919) +- implicitly private methods are now actually private +- deprecated reset() method is now private (call yargs() instead). +- **yargs-factory:** refactor yargs-factory to use class (#1895) +- .positional() now allowed at root level of yargs. +- **coerce:** coerce is now applied before validation. +- **async:** yargs now returns a promise if async or check are asynchronous. +- **middleware:** global middleware now applied when no command is configured. +- #1823 contains the following breaking API changes: + - now returns a promise if handler is async. + - onFinishCommand removed, in favor of being able to await promise. + - getCompletion now invokes callback with err and `completions, returns promise of completions. ### Features -* add commands alias (similar to options function) ([#1850](https://www.github.com/yargs/yargs/issues/1850)) ([00b74ad](https://www.github.com/yargs/yargs/commit/00b74adcb30ab89b4450ef7105ef1ad32d820ebf)) -* add parseSync/parseAsync method ([#1898](https://www.github.com/yargs/yargs/issues/1898)) ([6130ad8](https://www.github.com/yargs/yargs/commit/6130ad89b85dc49e34190e596e14a2fd3e668781)) -* add support for `showVersion`, similar to `showHelp` ([#1831](https://www.github.com/yargs/yargs/issues/1831)) ([1a1e2d5](https://www.github.com/yargs/yargs/commit/1a1e2d554dca3566bc174584394419be0120d207)) -* adds support for async builder ([#1888](https://www.github.com/yargs/yargs/issues/1888)) ([ade29b8](https://www.github.com/yargs/yargs/commit/ade29b864abecaa8c4f8dcc3493f5eb24fb73d84)), closes [#1042](https://www.github.com/yargs/yargs/issues/1042) -* allow calling standard completion function from custom one ([#1855](https://www.github.com/yargs/yargs/issues/1855)) ([31765cb](https://www.github.com/yargs/yargs/commit/31765cbdce812ee5c16aaae70ab523a2c7e0fcec)) -* allow default completion to be referenced and modified, in custom completion ([#1878](https://www.github.com/yargs/yargs/issues/1878)) ([01619f6](https://www.github.com/yargs/yargs/commit/01619f6191a3ab16bf6b77456d4e9dfa80533907)) -* **async:** add support for async check and coerce ([#1872](https://www.github.com/yargs/yargs/issues/1872)) ([8b95f57](https://www.github.com/yargs/yargs/commit/8b95f57bb2a49b098c6bf23cea88c6f900a34f89)) -* improve support for async/await ([#1823](https://www.github.com/yargs/yargs/issues/1823)) ([169b815](https://www.github.com/yargs/yargs/commit/169b815df7ae190965f04030f28adc3ab92bb4b5)) -* **locale:** add Ukrainian locale ([#1893](https://www.github.com/yargs/yargs/issues/1893)) ([c872dfc](https://www.github.com/yargs/yargs/commit/c872dfc1d87ebaa7fcc79801f649318a16195495)) -* **middleware:** async middleware can now be used before validation. ([e0f9363](https://www.github.com/yargs/yargs/commit/e0f93636e04fa7e02a2c3b1fe465b6a14aa1f06d)) -* **middleware:** global middleware now applied when no command is configured. ([e0f9363](https://www.github.com/yargs/yargs/commit/e0f93636e04fa7e02a2c3b1fe465b6a14aa1f06d)) -* **node:** drop Node 10 ([#1919](https://www.github.com/yargs/yargs/issues/1919)) ([5edeb9e](https://www.github.com/yargs/yargs/commit/5edeb9ea17b1f0190a3590508f2e7911b5f70659)) - +- add commands alias (similar to options function) ([#1850](https://www.github.com/yargs/yargs/issues/1850)) ([00b74ad](https://www.github.com/yargs/yargs/commit/00b74adcb30ab89b4450ef7105ef1ad32d820ebf)) +- add parseSync/parseAsync method ([#1898](https://www.github.com/yargs/yargs/issues/1898)) ([6130ad8](https://www.github.com/yargs/yargs/commit/6130ad89b85dc49e34190e596e14a2fd3e668781)) +- add support for `showVersion`, similar to `showHelp` ([#1831](https://www.github.com/yargs/yargs/issues/1831)) ([1a1e2d5](https://www.github.com/yargs/yargs/commit/1a1e2d554dca3566bc174584394419be0120d207)) +- adds support for async builder ([#1888](https://www.github.com/yargs/yargs/issues/1888)) ([ade29b8](https://www.github.com/yargs/yargs/commit/ade29b864abecaa8c4f8dcc3493f5eb24fb73d84)), closes [#1042](https://www.github.com/yargs/yargs/issues/1042) +- allow calling standard completion function from custom one ([#1855](https://www.github.com/yargs/yargs/issues/1855)) ([31765cb](https://www.github.com/yargs/yargs/commit/31765cbdce812ee5c16aaae70ab523a2c7e0fcec)) +- allow default completion to be referenced and modified, in custom completion ([#1878](https://www.github.com/yargs/yargs/issues/1878)) ([01619f6](https://www.github.com/yargs/yargs/commit/01619f6191a3ab16bf6b77456d4e9dfa80533907)) +- **async:** add support for async check and coerce ([#1872](https://www.github.com/yargs/yargs/issues/1872)) ([8b95f57](https://www.github.com/yargs/yargs/commit/8b95f57bb2a49b098c6bf23cea88c6f900a34f89)) +- improve support for async/await ([#1823](https://www.github.com/yargs/yargs/issues/1823)) ([169b815](https://www.github.com/yargs/yargs/commit/169b815df7ae190965f04030f28adc3ab92bb4b5)) +- **locale:** add Ukrainian locale ([#1893](https://www.github.com/yargs/yargs/issues/1893)) ([c872dfc](https://www.github.com/yargs/yargs/commit/c872dfc1d87ebaa7fcc79801f649318a16195495)) +- **middleware:** async middleware can now be used before validation. ([e0f9363](https://www.github.com/yargs/yargs/commit/e0f93636e04fa7e02a2c3b1fe465b6a14aa1f06d)) +- **middleware:** global middleware now applied when no command is configured. ([e0f9363](https://www.github.com/yargs/yargs/commit/e0f93636e04fa7e02a2c3b1fe465b6a14aa1f06d)) +- **node:** drop Node 10 ([#1919](https://www.github.com/yargs/yargs/issues/1919)) ([5edeb9e](https://www.github.com/yargs/yargs/commit/5edeb9ea17b1f0190a3590508f2e7911b5f70659)) ### Bug Fixes -* always cache help message when running commands ([#1865](https://www.github.com/yargs/yargs/issues/1865)) ([d57ca77](https://www.github.com/yargs/yargs/commit/d57ca7751d533d7e0f216cd9fbf7c2b0ec98f791)), closes [#1853](https://www.github.com/yargs/yargs/issues/1853) -* **async:** don't call parse callback until async ops complete ([#1896](https://www.github.com/yargs/yargs/issues/1896)) ([a93f5ff](https://www.github.com/yargs/yargs/commit/a93f5ff35d7c09b01e0ca93d7d855d2b26593165)), closes [#1888](https://www.github.com/yargs/yargs/issues/1888) -* **builder:** apply default builder for showHelp/getHelp ([#1913](https://www.github.com/yargs/yargs/issues/1913)) ([395bb67](https://www.github.com/yargs/yargs/commit/395bb67749787d269cabe80ffc3133c2f6958aeb)), closes [#1912](https://www.github.com/yargs/yargs/issues/1912) -* **builder:** nested builder is now awaited ([#1925](https://www.github.com/yargs/yargs/issues/1925)) ([b5accd6](https://www.github.com/yargs/yargs/commit/b5accd64ccbd3ffb800517fb40d0f59382515fbb)) -* **coerce:** options using coerce now displayed in help ([#1911](https://www.github.com/yargs/yargs/issues/1911)) ([d2128cc](https://www.github.com/yargs/yargs/commit/d2128cc4ffd411eed7111e6a3c561948330e4f6f)), closes [#1909](https://www.github.com/yargs/yargs/issues/1909) -* completion script name clashing on bash ([#1903](https://www.github.com/yargs/yargs/issues/1903)) ([8f62d9a](https://www.github.com/yargs/yargs/commit/8f62d9a9e8bebf86f988c100ad3c417dc32b2471)) -* **deno:** use actual names for keys instead of inferring ([#1891](https://www.github.com/yargs/yargs/issues/1891)) ([b96ef01](https://www.github.com/yargs/yargs/commit/b96ef01b16bc5377b79d7914dd5495068037fe7b)) -* exclude positionals from default completion ([#1881](https://www.github.com/yargs/yargs/issues/1881)) ([0175677](https://www.github.com/yargs/yargs/commit/0175677b79ffe50a9c5477631288ae10120b8a32)) -* https://github.com/yargs/yargs/issues/1841#issuecomment-804770453 ([b96ef01](https://www.github.com/yargs/yargs/commit/b96ef01b16bc5377b79d7914dd5495068037fe7b)) -* showHelp() and .getHelp() now return same output for commands as --help ([#1826](https://www.github.com/yargs/yargs/issues/1826)) ([36abf26](https://www.github.com/yargs/yargs/commit/36abf26919b5a19f3adec08598539851c34b7086)) -* zsh completion is now autoloadable ([#1856](https://www.github.com/yargs/yargs/issues/1856)) ([d731f9f](https://www.github.com/yargs/yargs/commit/d731f9f9adbc11f918e918443c5bff4149fc6681)) - +- always cache help message when running commands ([#1865](https://www.github.com/yargs/yargs/issues/1865)) ([d57ca77](https://www.github.com/yargs/yargs/commit/d57ca7751d533d7e0f216cd9fbf7c2b0ec98f791)), closes [#1853](https://www.github.com/yargs/yargs/issues/1853) +- **async:** don't call parse callback until async ops complete ([#1896](https://www.github.com/yargs/yargs/issues/1896)) ([a93f5ff](https://www.github.com/yargs/yargs/commit/a93f5ff35d7c09b01e0ca93d7d855d2b26593165)), closes [#1888](https://www.github.com/yargs/yargs/issues/1888) +- **builder:** apply default builder for showHelp/getHelp ([#1913](https://www.github.com/yargs/yargs/issues/1913)) ([395bb67](https://www.github.com/yargs/yargs/commit/395bb67749787d269cabe80ffc3133c2f6958aeb)), closes [#1912](https://www.github.com/yargs/yargs/issues/1912) +- **builder:** nested builder is now awaited ([#1925](https://www.github.com/yargs/yargs/issues/1925)) ([b5accd6](https://www.github.com/yargs/yargs/commit/b5accd64ccbd3ffb800517fb40d0f59382515fbb)) +- **coerce:** options using coerce now displayed in help ([#1911](https://www.github.com/yargs/yargs/issues/1911)) ([d2128cc](https://www.github.com/yargs/yargs/commit/d2128cc4ffd411eed7111e6a3c561948330e4f6f)), closes [#1909](https://www.github.com/yargs/yargs/issues/1909) +- completion script name clashing on bash ([#1903](https://www.github.com/yargs/yargs/issues/1903)) ([8f62d9a](https://www.github.com/yargs/yargs/commit/8f62d9a9e8bebf86f988c100ad3c417dc32b2471)) +- **deno:** use actual names for keys instead of inferring ([#1891](https://www.github.com/yargs/yargs/issues/1891)) ([b96ef01](https://www.github.com/yargs/yargs/commit/b96ef01b16bc5377b79d7914dd5495068037fe7b)) +- exclude positionals from default completion ([#1881](https://www.github.com/yargs/yargs/issues/1881)) ([0175677](https://www.github.com/yargs/yargs/commit/0175677b79ffe50a9c5477631288ae10120b8a32)) +- https://github.com/yargs/yargs/issues/1841#issuecomment-804770453 ([b96ef01](https://www.github.com/yargs/yargs/commit/b96ef01b16bc5377b79d7914dd5495068037fe7b)) +- showHelp() and .getHelp() now return same output for commands as --help ([#1826](https://www.github.com/yargs/yargs/issues/1826)) ([36abf26](https://www.github.com/yargs/yargs/commit/36abf26919b5a19f3adec08598539851c34b7086)) +- zsh completion is now autoloadable ([#1856](https://www.github.com/yargs/yargs/issues/1856)) ([d731f9f](https://www.github.com/yargs/yargs/commit/d731f9f9adbc11f918e918443c5bff4149fc6681)) ### Code Refactoring -* **coerce:** coerce is now applied before validation. ([8b95f57](https://www.github.com/yargs/yargs/commit/8b95f57bb2a49b098c6bf23cea88c6f900a34f89)) -* deprecated reset() method is now private (call yargs() instead). ([376f892](https://www.github.com/yargs/yargs/commit/376f89242733dcd4ecb8040685c40ae1d622931d)) -* implicitly private methods are now actually private ([376f892](https://www.github.com/yargs/yargs/commit/376f89242733dcd4ecb8040685c40ae1d622931d)) -* **yargs-factory:** refactor yargs-factory to use class ([#1895](https://www.github.com/yargs/yargs/issues/1895)) ([376f892](https://www.github.com/yargs/yargs/commit/376f89242733dcd4ecb8040685c40ae1d622931d)) +- **coerce:** coerce is now applied before validation. ([8b95f57](https://www.github.com/yargs/yargs/commit/8b95f57bb2a49b098c6bf23cea88c6f900a34f89)) +- deprecated reset() method is now private (call yargs() instead). ([376f892](https://www.github.com/yargs/yargs/commit/376f89242733dcd4ecb8040685c40ae1d622931d)) +- implicitly private methods are now actually private ([376f892](https://www.github.com/yargs/yargs/commit/376f89242733dcd4ecb8040685c40ae1d622931d)) +- **yargs-factory:** refactor yargs-factory to use class ([#1895](https://www.github.com/yargs/yargs/issues/1895)) ([376f892](https://www.github.com/yargs/yargs/commit/376f89242733dcd4ecb8040685c40ae1d622931d)) ## [16.2.0](https://www.github.com/yargs/yargs/compare/v16.1.1...v16.2.0) (2020-12-05) - ### Features -* command() now accepts an array of modules ([f415388](https://www.github.com/yargs/yargs/commit/f415388cc454d02786c65c50dd6c7a0cf9d8b842)) - +- command() now accepts an array of modules ([f415388](https://www.github.com/yargs/yargs/commit/f415388cc454d02786c65c50dd6c7a0cf9d8b842)) ### Bug Fixes -* add package.json to module exports ([#1818](https://www.github.com/yargs/yargs/issues/1818)) ([d783a49](https://www.github.com/yargs/yargs/commit/d783a49a7f21c9bbd4eec2990268f3244c4d5662)), closes [#1817](https://www.github.com/yargs/yargs/issues/1817) +- add package.json to module exports ([#1818](https://www.github.com/yargs/yargs/issues/1818)) ([d783a49](https://www.github.com/yargs/yargs/commit/d783a49a7f21c9bbd4eec2990268f3244c4d5662)), closes [#1817](https://www.github.com/yargs/yargs/issues/1817) ### [16.1.1](https://www.github.com/yargs/yargs/compare/v16.1.0...v16.1.1) (2020-11-15) - ### Bug Fixes -* expose helpers for legacy versions of Node.js ([#1801](https://www.github.com/yargs/yargs/issues/1801)) ([107deaa](https://www.github.com/yargs/yargs/commit/107deaa4f68b7bc3f2386041e1f4fe0272b29c0a)) -* **deno:** get yargs working on deno@1.5.x ([#1799](https://www.github.com/yargs/yargs/issues/1799)) ([cb01c98](https://www.github.com/yargs/yargs/commit/cb01c98c44e30f55c2dc9434caef524ae433d9a4)) +- expose helpers for legacy versions of Node.js ([#1801](https://www.github.com/yargs/yargs/issues/1801)) ([107deaa](https://www.github.com/yargs/yargs/commit/107deaa4f68b7bc3f2386041e1f4fe0272b29c0a)) +- **deno:** get yargs working on deno@1.5.x ([#1799](https://www.github.com/yargs/yargs/issues/1799)) ([cb01c98](https://www.github.com/yargs/yargs/commit/cb01c98c44e30f55c2dc9434caef524ae433d9a4)) ## [16.1.0](https://www.github.com/yargs/yargs/compare/v16.0.3...v16.1.0) (2020-10-15) - ### Features -* expose hideBin helper for CJS ([#1768](https://www.github.com/yargs/yargs/issues/1768)) ([63e1173](https://www.github.com/yargs/yargs/commit/63e1173bb47dc651c151973a16ef659082a9ae66)) - +- expose hideBin helper for CJS ([#1768](https://www.github.com/yargs/yargs/issues/1768)) ([63e1173](https://www.github.com/yargs/yargs/commit/63e1173bb47dc651c151973a16ef659082a9ae66)) ### Bug Fixes -* **deno:** update types for deno ^1.4.0 ([#1772](https://www.github.com/yargs/yargs/issues/1772)) ([0801752](https://www.github.com/yargs/yargs/commit/080175207d281be63edf90adfe4f0568700b0bf5)) -* **exports:** node 13.0-13.6 require a string fallback ([#1776](https://www.github.com/yargs/yargs/issues/1776)) ([b45c43a](https://www.github.com/yargs/yargs/commit/b45c43a5f64b565c3794f9792150eaeec4e00b69)) -* **modules:** module path was incorrect ([#1759](https://www.github.com/yargs/yargs/issues/1759)) ([95a4a0a](https://www.github.com/yargs/yargs/commit/95a4a0ac573cfe158e6e4bc8c8682ebd1644a198)) -* **positional:** positional strings no longer drop decimals ([#1761](https://www.github.com/yargs/yargs/issues/1761)) ([e1a300f](https://www.github.com/yargs/yargs/commit/e1a300f1293ad821c900284616337f080b207980)) -* make positionals in -- count towards validation ([#1752](https://www.github.com/yargs/yargs/issues/1752)) ([eb2b29d](https://www.github.com/yargs/yargs/commit/eb2b29d34f1a41e0fd6c4e841960e5bfc329dc3c)) +- **deno:** update types for deno ^1.4.0 ([#1772](https://www.github.com/yargs/yargs/issues/1772)) ([0801752](https://www.github.com/yargs/yargs/commit/080175207d281be63edf90adfe4f0568700b0bf5)) +- **exports:** node 13.0-13.6 require a string fallback ([#1776](https://www.github.com/yargs/yargs/issues/1776)) ([b45c43a](https://www.github.com/yargs/yargs/commit/b45c43a5f64b565c3794f9792150eaeec4e00b69)) +- **modules:** module path was incorrect ([#1759](https://www.github.com/yargs/yargs/issues/1759)) ([95a4a0a](https://www.github.com/yargs/yargs/commit/95a4a0ac573cfe158e6e4bc8c8682ebd1644a198)) +- **positional:** positional strings no longer drop decimals ([#1761](https://www.github.com/yargs/yargs/issues/1761)) ([e1a300f](https://www.github.com/yargs/yargs/commit/e1a300f1293ad821c900284616337f080b207980)) +- make positionals in -- count towards validation ([#1752](https://www.github.com/yargs/yargs/issues/1752)) ([eb2b29d](https://www.github.com/yargs/yargs/commit/eb2b29d34f1a41e0fd6c4e841960e5bfc329dc3c)) ### [16.0.3](https://www.github.com/yargs/yargs/compare/v16.0.2...v16.0.3) (2020-09-10) - ### Bug Fixes -* move yargs.cjs to yargs to fix Node 10 imports ([#1747](https://www.github.com/yargs/yargs/issues/1747)) ([5bfb85b](https://www.github.com/yargs/yargs/commit/5bfb85b33b85db8a44b5f7a700a8e4dbaf022df0)) +- move yargs.cjs to yargs to fix Node 10 imports ([#1747](https://www.github.com/yargs/yargs/issues/1747)) ([5bfb85b](https://www.github.com/yargs/yargs/commit/5bfb85b33b85db8a44b5f7a700a8e4dbaf022df0)) ### [16.0.2](https://www.github.com/yargs/yargs/compare/v16.0.1...v16.0.2) (2020-09-09) - ### Bug Fixes -* **typescript:** yargs-parser was breaking @types/yargs ([#1745](https://www.github.com/yargs/yargs/issues/1745)) ([2253284](https://www.github.com/yargs/yargs/commit/2253284b233cceabd8db677b81c5bf1755eef230)) +- **typescript:** yargs-parser was breaking @types/yargs ([#1745](https://www.github.com/yargs/yargs/issues/1745)) ([2253284](https://www.github.com/yargs/yargs/commit/2253284b233cceabd8db677b81c5bf1755eef230)) ### [16.0.1](https://www.github.com/yargs/yargs/compare/v16.0.0...v16.0.1) (2020-09-09) - ### Bug Fixes -* code was not passed to process.exit ([#1742](https://www.github.com/yargs/yargs/issues/1742)) ([d1a9930](https://www.github.com/yargs/yargs/commit/d1a993035a2f76c138460052cf19425f9684b637)) +- code was not passed to process.exit ([#1742](https://www.github.com/yargs/yargs/issues/1742)) ([d1a9930](https://www.github.com/yargs/yargs/commit/d1a993035a2f76c138460052cf19425f9684b637)) ## [16.0.0](https://www.github.com/yargs/yargs/compare/v15.4.2...v16.0.0) (2020-09-09) - ### ⚠ BREAKING CHANGES -* tweaks to ESM/Deno API surface: now exports yargs function by default; getProcessArgvWithoutBin becomes hideBin; types now exported for Deno. -* find-up replaced with escalade; export map added (limits importable files in Node >= 12); yarser-parser@19.x.x (new decamelize/camelcase implementation). -* **usage:** single character aliases are now shown first in help output -* rebase helper is no longer provided on yargs instance. -* drop support for EOL Node 8 (#1686) +- tweaks to ESM/Deno API surface: now exports yargs function by default; getProcessArgvWithoutBin becomes hideBin; types now exported for Deno. +- find-up replaced with escalade; export map added (limits importable files in Node >= 12); yarser-parser@19.x.x (new decamelize/camelcase implementation). +- **usage:** single character aliases are now shown first in help output +- rebase helper is no longer provided on yargs instance. +- drop support for EOL Node 8 (#1686) ### Features -* adds strictOptions() ([#1738](https://www.github.com/yargs/yargs/issues/1738)) ([b215fba](https://www.github.com/yargs/yargs/commit/b215fba0ed6e124e5aad6cf22c8d5875661c63a3)) -* **helpers:** rebase, Parser, applyExtends now blessed helpers ([#1733](https://www.github.com/yargs/yargs/issues/1733)) ([c7debe8](https://www.github.com/yargs/yargs/commit/c7debe8eb1e5bc6ea20b5ed68026c56e5ebec9e1)) -* adds support for ESM and Deno ([#1708](https://www.github.com/yargs/yargs/issues/1708)) ([ac6d5d1](https://www.github.com/yargs/yargs/commit/ac6d5d105a75711fe703f6a39dad5181b383d6c6)) -* drop support for EOL Node 8 ([#1686](https://www.github.com/yargs/yargs/issues/1686)) ([863937f](https://www.github.com/yargs/yargs/commit/863937f23c3102f804cdea78ee3097e28c7c289f)) -* i18n for ESM and Deno ([#1735](https://www.github.com/yargs/yargs/issues/1735)) ([c71783a](https://www.github.com/yargs/yargs/commit/c71783a5a898a0c0e92ac501c939a3ec411ac0c1)) -* tweaks to API surface based on user feedback ([#1726](https://www.github.com/yargs/yargs/issues/1726)) ([4151fee](https://www.github.com/yargs/yargs/commit/4151fee4c33a97d26bc40de7e623e5b0eb87e9bb)) -* **usage:** single char aliases first in help ([#1574](https://www.github.com/yargs/yargs/issues/1574)) ([a552990](https://www.github.com/yargs/yargs/commit/a552990c120646c2d85a5c9b628e1ce92a68e797)) - +- adds strictOptions() ([#1738](https://www.github.com/yargs/yargs/issues/1738)) ([b215fba](https://www.github.com/yargs/yargs/commit/b215fba0ed6e124e5aad6cf22c8d5875661c63a3)) +- **helpers:** rebase, Parser, applyExtends now blessed helpers ([#1733](https://www.github.com/yargs/yargs/issues/1733)) ([c7debe8](https://www.github.com/yargs/yargs/commit/c7debe8eb1e5bc6ea20b5ed68026c56e5ebec9e1)) +- adds support for ESM and Deno ([#1708](https://www.github.com/yargs/yargs/issues/1708)) ([ac6d5d1](https://www.github.com/yargs/yargs/commit/ac6d5d105a75711fe703f6a39dad5181b383d6c6)) +- drop support for EOL Node 8 ([#1686](https://www.github.com/yargs/yargs/issues/1686)) ([863937f](https://www.github.com/yargs/yargs/commit/863937f23c3102f804cdea78ee3097e28c7c289f)) +- i18n for ESM and Deno ([#1735](https://www.github.com/yargs/yargs/issues/1735)) ([c71783a](https://www.github.com/yargs/yargs/commit/c71783a5a898a0c0e92ac501c939a3ec411ac0c1)) +- tweaks to API surface based on user feedback ([#1726](https://www.github.com/yargs/yargs/issues/1726)) ([4151fee](https://www.github.com/yargs/yargs/commit/4151fee4c33a97d26bc40de7e623e5b0eb87e9bb)) +- **usage:** single char aliases first in help ([#1574](https://www.github.com/yargs/yargs/issues/1574)) ([a552990](https://www.github.com/yargs/yargs/commit/a552990c120646c2d85a5c9b628e1ce92a68e797)) ### Bug Fixes -* **yargs:** add missing command(module) signature ([#1707](https://www.github.com/yargs/yargs/issues/1707)) ([0f81024](https://www.github.com/yargs/yargs/commit/0f810245494ccf13a35b7786d021b30fc95ecad5)), closes [#1704](https://www.github.com/yargs/yargs/issues/1704) +- **yargs:** add missing command(module) signature ([#1707](https://www.github.com/yargs/yargs/issues/1707)) ([0f81024](https://www.github.com/yargs/yargs/commit/0f810245494ccf13a35b7786d021b30fc95ecad5)), closes [#1704](https://www.github.com/yargs/yargs/issues/1704) [Older CHANGELOG Entries](https://github.com/yargs/yargs/blob/main/docs/CHANGELOG-historical.md) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 38a3bf2de..9b6dc8245 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/README.md b/README.md index 51f5b225d..050f487d7 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,13 @@ [![Slack][slack-image]][slack-url] ## Description + Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface. It gives you: -* commands and (grouped) options (`my-program.js serve --port=5000`). -* a dynamically generated help menu based on your arguments: +- commands and (grouped) options (`my-program.js serve --port=5000`). +- a dynamically generated help menu based on your arguments: ``` mocha [spec..] @@ -38,17 +39,19 @@ Rules & Behavior return a Promise [boolean] ``` -* bash-completion shortcuts for commands and options. -* and [tons more](/docs/api.md). +- bash-completion shortcuts for commands and options. +- and [tons more](/docs/api.md). ## Installation Stable version: + ```bash npm i yargs ``` Bleeding edge version with the most recent features: + ```bash npm i yargs@next ``` @@ -59,14 +62,14 @@ npm i yargs@next ```javascript #!/usr/bin/env node -const yargs = require('yargs/yargs') -const { hideBin } = require('yargs/helpers') -const argv = yargs(hideBin(process.argv)).argv +const yargs = require('yargs/yargs'); +const {hideBin} = require('yargs/helpers'); +const argv = yargs(hideBin(process.argv)).argv; if (argv.ships > 3 && argv.distance < 53.5) { - console.log('Plunder more riffiwobbles!') + console.log('Plunder more riffiwobbles!'); } else { - console.log('Retreat from the xupptumblers!') + console.log('Retreat from the xupptumblers!'); } ``` @@ -84,26 +87,30 @@ Retreat from the xupptumblers! ```javascript #!/usr/bin/env node -const yargs = require('yargs/yargs') -const { hideBin } = require('yargs/helpers') +const yargs = require('yargs/yargs'); +const {hideBin} = require('yargs/helpers'); yargs(hideBin(process.argv)) - .command('serve [port]', 'start the server', (yargs) => { - return yargs - .positional('port', { + .command( + 'serve [port]', + 'start the server', + yargs => { + return yargs.positional('port', { describe: 'port to bind on', - default: 5000 - }) - }, (argv) => { - if (argv.verbose) console.info(`start server on :${argv.port}`) - serve(argv.port) - }) + default: 5000, + }); + }, + argv => { + if (argv.verbose) console.info(`start server on :${argv.port}`); + serve(argv.port); + } + ) .option('verbose', { alias: 'v', type: 'boolean', - description: 'Run with verbose logging' + description: 'Run with verbose logging', }) - .parse() + .parse(); ``` Run the example above with `--help` to see the help for the application. @@ -125,20 +132,25 @@ See usage examples in [docs](/docs/typescript.md). As of `v16`, `yargs` supports [Deno](https://github.com/denoland/deno): ```typescript -import yargs from 'https://deno.land/x/yargs/deno.ts' -import { Arguments } from 'https://deno.land/x/yargs/deno-types.ts' +import yargs from 'https://deno.land/x/yargs/deno.ts'; +import {Arguments} from 'https://deno.land/x/yargs/deno-types.ts'; yargs(Deno.args) - .command('download ', 'download a list of files', (yargs: any) => { - return yargs.positional('files', { - describe: 'a list of files to do something with' - }) - }, (argv: Arguments) => { - console.info(argv) - }) + .command( + 'download ', + 'download a list of files', + (yargs: any) => { + return yargs.positional('files', { + describe: 'a list of files to do something with', + }); + }, + (argv: Arguments) => { + console.info(argv); + } + ) .strictCommands() .demandCommand(1) - .parse() + .parse(); ``` ### ESM @@ -146,15 +158,20 @@ yargs(Deno.args) As of `v16`,`yargs` supports ESM imports: ```js -import yargs from 'yargs' -import { hideBin } from 'yargs/helpers' +import yargs from 'yargs'; +import {hideBin} from 'yargs/helpers'; yargs(hideBin(process.argv)) - .command('curl ', 'fetch the contents of the URL', () => {}, (argv) => { - console.info(argv) - }) + .command( + 'curl ', + 'fetch the contents of the URL', + () => {}, + argv => { + console.info(argv); + } + ) .demandCommand(1) - .parse() + .parse(); ``` ### Usage in Browser @@ -169,21 +186,21 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc ### Table of Contents -* [Yargs' API](/docs/api.md) -* [Examples](/docs/examples.md) -* [Parsing Tricks](/docs/tricks.md) - * [Stop the Parser](/docs/tricks.md#stop) - * [Negating Boolean Arguments](/docs/tricks.md#negate) - * [Numbers](/docs/tricks.md#numbers) - * [Arrays](/docs/tricks.md#arrays) - * [Objects](/docs/tricks.md#objects) - * [Quotes](/docs/tricks.md#quotes) -* [Advanced Topics](/docs/advanced.md) - * [Composing Your App Using Commands](/docs/advanced.md#commands) - * [Building Configurable CLI Apps](/docs/advanced.md#configuration) - * [Customizing Yargs' Parser](/docs/advanced.md#customizing) - * [Bundling yargs](/docs/bundling.md) -* [Contributing](/contributing.md) +- [Yargs' API](/docs/api.md) +- [Examples](/docs/examples.md) +- [Parsing Tricks](/docs/tricks.md) + - [Stop the Parser](/docs/tricks.md#stop) + - [Negating Boolean Arguments](/docs/tricks.md#negate) + - [Numbers](/docs/tricks.md#numbers) + - [Arrays](/docs/tricks.md#arrays) + - [Objects](/docs/tricks.md#objects) + - [Quotes](/docs/tricks.md#quotes) +- [Advanced Topics](/docs/advanced.md) + - [Composing Your App Using Commands](/docs/advanced.md#commands) + - [Building Configurable CLI Apps](/docs/advanced.md#configuration) + - [Customizing Yargs' Parser](/docs/advanced.md#customizing) + - [Bundling yargs](/docs/bundling.md) +- [Contributing](/contributing.md) ## Supported Node.js Versions diff --git a/contributing.md b/contributing.md index dcd864d36..87a7c72dd 100644 --- a/contributing.md +++ b/contributing.md @@ -9,12 +9,12 @@ If you are looking to update the website, check out [yargs/yargs.github.io](http 1. Look through the existing issues and see if your idea is something new. 2. Create a new issue, or comment on an existing issue that you would like to help solve: - * it's usually best to get some feedback before proceeding to write code. + - it's usually best to get some feedback before proceeding to write code. 3. fork the yargs repo, and clone it to your computer: - * GitHub has [great documentation](https://help.github.com/articles/using-pull-requests/) regarding writing your first pull request. + - GitHub has [great documentation](https://help.github.com/articles/using-pull-requests/) regarding writing your first pull request. 4. make sure that you write unit-test for any code that you write for yargs: - * we use the [standard](https://github.com/feross/standard) coding style, - which will validate your style when you run tests. - * look through our extensive test suite in `/test` to get an idea for how - to write unit-tests for this codebase. + - we use the [standard](https://github.com/feross/standard) coding style, + which will validate your style when you run tests. + - look through our extensive test suite in `/test` to get an idea for how + to write unit-tests for this codebase. 5. make sure you are comfortable with the Code of Conduct outlined below. diff --git a/docs/CHANGELOG-historical.md b/docs/CHANGELOG-historical.md index 14979a5ad..ef1500f14 100644 --- a/docs/CHANGELOG-historical.md +++ b/docs/CHANGELOG-historical.md @@ -1,974 +1,822 @@ - ## [15.4.0](https://www.github.com/yargs/yargs/compare/v15.3.1...v15.4.0) (2020-06-30) - ### Features -* adds deprecation option for commands ([027a636](https://www.github.com/yargs/yargs/commit/027a6365b737e13116811a8ef43670196e1fa00a)) -* support array of examples ([#1682](https://www.github.com/yargs/yargs/issues/1682)) ([225ab82](https://www.github.com/yargs/yargs/commit/225ab8271938bed3a48d23175f3d580ce8cd1306)) - +- adds deprecation option for commands ([027a636](https://www.github.com/yargs/yargs/commit/027a6365b737e13116811a8ef43670196e1fa00a)) +- support array of examples ([#1682](https://www.github.com/yargs/yargs/issues/1682)) ([225ab82](https://www.github.com/yargs/yargs/commit/225ab8271938bed3a48d23175f3d580ce8cd1306)) ### Bug Fixes -* **docs:** describe usage of `.check()` in more detail ([932cd11](https://www.github.com/yargs/yargs/commit/932cd1177e93f5cc99edfe57a4028e30717bf8fb)) -* **i18n:** Japanese translation phrasing ([#1619](https://www.github.com/yargs/yargs/issues/1619)) ([0894175](https://www.github.com/yargs/yargs/commit/089417550ef5a5b8ce3578dd2a989191300b64cd)) -* **strict mode:** report default command unknown arguments ([#1626](https://www.github.com/yargs/yargs/issues/1626)) ([69f29a9](https://www.github.com/yargs/yargs/commit/69f29a9cd429d4bb99481238305390107ac75b02)) -* **usage:** translate 'options' group only when displaying help ([#1600](https://www.github.com/yargs/yargs/issues/1600)) ([e60b39b](https://www.github.com/yargs/yargs/commit/e60b39b9d3a912c06db43f87c86ba894142b6c1c)) - +- **docs:** describe usage of `.check()` in more detail ([932cd11](https://www.github.com/yargs/yargs/commit/932cd1177e93f5cc99edfe57a4028e30717bf8fb)) +- **i18n:** Japanese translation phrasing ([#1619](https://www.github.com/yargs/yargs/issues/1619)) ([0894175](https://www.github.com/yargs/yargs/commit/089417550ef5a5b8ce3578dd2a989191300b64cd)) +- **strict mode:** report default command unknown arguments ([#1626](https://www.github.com/yargs/yargs/issues/1626)) ([69f29a9](https://www.github.com/yargs/yargs/commit/69f29a9cd429d4bb99481238305390107ac75b02)) +- **usage:** translate 'options' group only when displaying help ([#1600](https://www.github.com/yargs/yargs/issues/1600)) ([e60b39b](https://www.github.com/yargs/yargs/commit/e60b39b9d3a912c06db43f87c86ba894142b6c1c)) ### Reverts -* Revert "chore(deps): update dependency eslint to v7 (#1656)" (#1673) ([34949f8](https://www.github.com/yargs/yargs/commit/34949f89ee7cdf88f7b315659df4b5f62f714842)), closes [#1656](https://www.github.com/yargs/yargs/issues/1656) [#1673](https://www.github.com/yargs/yargs/issues/1673) +- Revert "chore(deps): update dependency eslint to v7 (#1656)" (#1673) ([34949f8](https://www.github.com/yargs/yargs/commit/34949f89ee7cdf88f7b315659df4b5f62f714842)), closes [#1656](https://www.github.com/yargs/yargs/issues/1656) [#1673](https://www.github.com/yargs/yargs/issues/1673) ### [15.3.1](https://www.github.com/yargs/yargs/compare/v15.3.0...v15.3.1) (2020-03-16) - ### Bug Fixes -* \_\_proto\_\_ will now be replaced with \_\_\_proto\_\_\_ in parse ([#258](https://www.github.com/yargs/yargs-parser/issues/258)), patching a potential -prototype pollution vulnerability. This was reported by the Snyk Security Research Team. ([63810ca](https://www.github.com/yargs/yargs-parser/commit/63810ca1ae1a24b08293a4d971e70e058c7a41e2)) +- \_\_proto\_\_ will now be replaced with \_\_\_proto\_\_\_ in parse ([#258](https://www.github.com/yargs/yargs-parser/issues/258)), patching a potential + prototype pollution vulnerability. This was reported by the Snyk Security Research Team. ([63810ca](https://www.github.com/yargs/yargs-parser/commit/63810ca1ae1a24b08293a4d971e70e058c7a41e2)) ## [15.3.0](https://www.github.com/yargs/yargs/compare/v15.2.0...v15.3.0) (2020-03-08) - ### Features -* **yargs-parser:** introduce single-digit boolean aliases ([#1576](https://www.github.com/yargs/yargs/issues/1576)) ([3af7f04](https://www.github.com/yargs/yargs/commit/3af7f04cdbfcbd4b3f432aca5144d43f21958c39)) -* add usage for single-digit boolean aliases ([#1580](https://www.github.com/yargs/yargs/issues/1580)) ([6014e39](https://www.github.com/yargs/yargs/commit/6014e39bca3a1e8445aa0fb2a435f6181e344c45)) - +- **yargs-parser:** introduce single-digit boolean aliases ([#1576](https://www.github.com/yargs/yargs/issues/1576)) ([3af7f04](https://www.github.com/yargs/yargs/commit/3af7f04cdbfcbd4b3f432aca5144d43f21958c39)) +- add usage for single-digit boolean aliases ([#1580](https://www.github.com/yargs/yargs/issues/1580)) ([6014e39](https://www.github.com/yargs/yargs/commit/6014e39bca3a1e8445aa0fb2a435f6181e344c45)) ### Bug Fixes -* address ambiguity between nargs of 1 and requiresArg ([#1572](https://www.github.com/yargs/yargs/issues/1572)) ([a5edc32](https://www.github.com/yargs/yargs/commit/a5edc328ecb3f90d1ba09cfe70a0040f68adf50a)) +- address ambiguity between nargs of 1 and requiresArg ([#1572](https://www.github.com/yargs/yargs/issues/1572)) ([a5edc32](https://www.github.com/yargs/yargs/commit/a5edc328ecb3f90d1ba09cfe70a0040f68adf50a)) ## [15.2.0](https://www.github.com/yargs/yargs/compare/v15.1.0...v15.2.0) (2020-03-01) - ### ⚠ BREAKING CHANGES -* **deps:** yargs-parser@17.0.0 no longer implicitly creates arrays out of boolean -arguments when duplicates are provided +- **deps:** yargs-parser@17.0.0 no longer implicitly creates arrays out of boolean + arguments when duplicates are provided ### Features -* **completion:** takes negated flags into account when boolean-negation is set ([#1509](https://www.github.com/yargs/yargs/issues/1509)) ([7293ad5](https://www.github.com/yargs/yargs/commit/7293ad50d20ea0fb7dd1ac9b925e90e1bd95dea8)) -* **deps:** pull in yargs-parser@17.0.0 ([#1553](https://www.github.com/yargs/yargs/issues/1553)) ([b9409da](https://www.github.com/yargs/yargs/commit/b9409da199ebca515a848489c206b807fab2e65d)) -* deprecateOption ([#1559](https://www.github.com/yargs/yargs/issues/1559)) ([8aae333](https://www.github.com/yargs/yargs/commit/8aae3332251d09fa136db17ef4a40d83fa052bc4)) -* display appropriate $0 for electron apps ([#1536](https://www.github.com/yargs/yargs/issues/1536)) ([d0e4379](https://www.github.com/yargs/yargs/commit/d0e437912917d6a66bb5128992fa2f566a5f830b)) -* introduces strictCommands() subset of strict mode ([#1540](https://www.github.com/yargs/yargs/issues/1540)) ([1d4cca3](https://www.github.com/yargs/yargs/commit/1d4cca395a98b395e6318f0505fc73bef8b01350)) -* **deps:** yargs-parser with 'greedy-array' configuration ([#1569](https://www.github.com/yargs/yargs/issues/1569)) ([a03a320](https://www.github.com/yargs/yargs/commit/a03a320dbf5c0ce33d829a857fc04a651c0bb53e)) - +- **completion:** takes negated flags into account when boolean-negation is set ([#1509](https://www.github.com/yargs/yargs/issues/1509)) ([7293ad5](https://www.github.com/yargs/yargs/commit/7293ad50d20ea0fb7dd1ac9b925e90e1bd95dea8)) +- **deps:** pull in yargs-parser@17.0.0 ([#1553](https://www.github.com/yargs/yargs/issues/1553)) ([b9409da](https://www.github.com/yargs/yargs/commit/b9409da199ebca515a848489c206b807fab2e65d)) +- deprecateOption ([#1559](https://www.github.com/yargs/yargs/issues/1559)) ([8aae333](https://www.github.com/yargs/yargs/commit/8aae3332251d09fa136db17ef4a40d83fa052bc4)) +- display appropriate $0 for electron apps ([#1536](https://www.github.com/yargs/yargs/issues/1536)) ([d0e4379](https://www.github.com/yargs/yargs/commit/d0e437912917d6a66bb5128992fa2f566a5f830b)) +- introduces strictCommands() subset of strict mode ([#1540](https://www.github.com/yargs/yargs/issues/1540)) ([1d4cca3](https://www.github.com/yargs/yargs/commit/1d4cca395a98b395e6318f0505fc73bef8b01350)) +- **deps:** yargs-parser with 'greedy-array' configuration ([#1569](https://www.github.com/yargs/yargs/issues/1569)) ([a03a320](https://www.github.com/yargs/yargs/commit/a03a320dbf5c0ce33d829a857fc04a651c0bb53e)) ### Bug Fixes -* help always displayed for the first command parsed having an async handler ([#1535](https://www.github.com/yargs/yargs/issues/1535)) ([d585b30](https://www.github.com/yargs/yargs/commit/d585b303a43746201b05c9c9fda94a444634df33)) -* **deps:** fix enumeration for normalized path arguments ([#1567](https://www.github.com/yargs/yargs/issues/1567)) ([0b5b1b0](https://www.github.com/yargs/yargs/commit/0b5b1b0e5f4f9baf393c48e9cc2bc85c1b67a47a)) -* **locales:** only translate default option group name ([acc16de](https://www.github.com/yargs/yargs/commit/acc16de6b846ea7332db753646a9cec76b589162)) -* **locales:** remove extra space in French for 'default' ([#1564](https://www.github.com/yargs/yargs/issues/1564)) ([ecfc2c4](https://www.github.com/yargs/yargs/commit/ecfc2c474575c6cdbc6d273c94c13181bd1dbaa6)) -* **translations:** add French translation for unknown command ([#1563](https://www.github.com/yargs/yargs/issues/1563)) ([18b0b75](https://www.github.com/yargs/yargs/commit/18b0b752424bf560271e670ff95a0f90c8386787)) -* **translations:** fix pluralization in error messages. ([#1557](https://www.github.com/yargs/yargs/issues/1557)) ([94fa38c](https://www.github.com/yargs/yargs/commit/94fa38cbab8d86943e87bf41d368ed56dffa6835)) -* **yargs:** correct support of bundled electron apps ([#1554](https://www.github.com/yargs/yargs/issues/1554)) ([a0b61ac](https://www.github.com/yargs/yargs/commit/a0b61ac21e2b554aa73dbf1a66d4a7af94047c2f)) +- help always displayed for the first command parsed having an async handler ([#1535](https://www.github.com/yargs/yargs/issues/1535)) ([d585b30](https://www.github.com/yargs/yargs/commit/d585b303a43746201b05c9c9fda94a444634df33)) +- **deps:** fix enumeration for normalized path arguments ([#1567](https://www.github.com/yargs/yargs/issues/1567)) ([0b5b1b0](https://www.github.com/yargs/yargs/commit/0b5b1b0e5f4f9baf393c48e9cc2bc85c1b67a47a)) +- **locales:** only translate default option group name ([acc16de](https://www.github.com/yargs/yargs/commit/acc16de6b846ea7332db753646a9cec76b589162)) +- **locales:** remove extra space in French for 'default' ([#1564](https://www.github.com/yargs/yargs/issues/1564)) ([ecfc2c4](https://www.github.com/yargs/yargs/commit/ecfc2c474575c6cdbc6d273c94c13181bd1dbaa6)) +- **translations:** add French translation for unknown command ([#1563](https://www.github.com/yargs/yargs/issues/1563)) ([18b0b75](https://www.github.com/yargs/yargs/commit/18b0b752424bf560271e670ff95a0f90c8386787)) +- **translations:** fix pluralization in error messages. ([#1557](https://www.github.com/yargs/yargs/issues/1557)) ([94fa38c](https://www.github.com/yargs/yargs/commit/94fa38cbab8d86943e87bf41d368ed56dffa6835)) +- **yargs:** correct support of bundled electron apps ([#1554](https://www.github.com/yargs/yargs/issues/1554)) ([a0b61ac](https://www.github.com/yargs/yargs/commit/a0b61ac21e2b554aa73dbf1a66d4a7af94047c2f)) ## [15.1.0](https://www.github.com/yargs/yargs/compare/v15.0.2...v15.1.0) (2020-01-02) - ### Features -* **lang:** add Finnish localization (language code fi) ([222c8fe](https://www.github.com/yargs/yargs/commit/222c8fef2e2ad46e314c337dec96940f896bec35)) -* complete short options with a single dash ([#1507](https://www.github.com/yargs/yargs/issues/1507)) ([99011ab](https://www.github.com/yargs/yargs/commit/99011ab5ba90232506ece0a17e59e2001a1ab562)) -* onFinishCommand handler ([#1473](https://www.github.com/yargs/yargs/issues/1473)) ([fe380cd](https://www.github.com/yargs/yargs/commit/fe380cd356aa33aef0449facd59c22cab8930ac9)) - +- **lang:** add Finnish localization (language code fi) ([222c8fe](https://www.github.com/yargs/yargs/commit/222c8fef2e2ad46e314c337dec96940f896bec35)) +- complete short options with a single dash ([#1507](https://www.github.com/yargs/yargs/issues/1507)) ([99011ab](https://www.github.com/yargs/yargs/commit/99011ab5ba90232506ece0a17e59e2001a1ab562)) +- onFinishCommand handler ([#1473](https://www.github.com/yargs/yargs/issues/1473)) ([fe380cd](https://www.github.com/yargs/yargs/commit/fe380cd356aa33aef0449facd59c22cab8930ac9)) ### Bug Fixes -* getCompletion() was not working for options ([#1495](https://www.github.com/yargs/yargs/issues/1495)) ([463feb2](https://www.github.com/yargs/yargs/commit/463feb2870158eb9df670222b0f0a40a05cf18d0)) -* misspelling of package.json `engines` field ([0891d0e](https://www.github.com/yargs/yargs/commit/0891d0ed35b30c83a6d9e9f6a5c5f84d13c546a0)) -* populate positionals when unknown-options-as-args is set ([#1508](https://www.github.com/yargs/yargs/issues/1508)) ([bb0f2eb](https://www.github.com/yargs/yargs/commit/bb0f2eb996fa4e19d330b31a01c2036cafa99a7e)), closes [#1444](https://www.github.com/yargs/yargs/issues/1444) -* show 2 dashes on help for single digit option key or alias ([#1493](https://www.github.com/yargs/yargs/issues/1493)) ([63b3dd3](https://www.github.com/yargs/yargs/commit/63b3dd31a455d428902220c1992ae930e18aff5c)) -* **docs:** use recommended cjs import syntax for ts examples ([#1513](https://www.github.com/yargs/yargs/issues/1513)) ([f9a18bf](https://www.github.com/yargs/yargs/commit/f9a18bfd624a5013108084f690cd8a1de794c430)) +- getCompletion() was not working for options ([#1495](https://www.github.com/yargs/yargs/issues/1495)) ([463feb2](https://www.github.com/yargs/yargs/commit/463feb2870158eb9df670222b0f0a40a05cf18d0)) +- misspelling of package.json `engines` field ([0891d0e](https://www.github.com/yargs/yargs/commit/0891d0ed35b30c83a6d9e9f6a5c5f84d13c546a0)) +- populate positionals when unknown-options-as-args is set ([#1508](https://www.github.com/yargs/yargs/issues/1508)) ([bb0f2eb](https://www.github.com/yargs/yargs/commit/bb0f2eb996fa4e19d330b31a01c2036cafa99a7e)), closes [#1444](https://www.github.com/yargs/yargs/issues/1444) +- show 2 dashes on help for single digit option key or alias ([#1493](https://www.github.com/yargs/yargs/issues/1493)) ([63b3dd3](https://www.github.com/yargs/yargs/commit/63b3dd31a455d428902220c1992ae930e18aff5c)) +- **docs:** use recommended cjs import syntax for ts examples ([#1513](https://www.github.com/yargs/yargs/issues/1513)) ([f9a18bf](https://www.github.com/yargs/yargs/commit/f9a18bfd624a5013108084f690cd8a1de794c430)) ### [15.0.2](https://www.github.com/yargs/yargs/compare/v15.0.1...v15.0.2) (2019-11-19) - ### Bug Fixes -* temporary fix for libraries that call Object.freeze() ([#1483](https://www.github.com/yargs/yargs/issues/1483)) ([99c2dc8](https://www.github.com/yargs/yargs/commit/99c2dc850e67c606644f8b0c0bca1a59c87dcbcd)) +- temporary fix for libraries that call Object.freeze() ([#1483](https://www.github.com/yargs/yargs/issues/1483)) ([99c2dc8](https://www.github.com/yargs/yargs/commit/99c2dc850e67c606644f8b0c0bca1a59c87dcbcd)) ### [15.0.1](https://www.github.com/yargs/yargs/compare/v15.0.0...v15.0.1) (2019-11-16) - ### Bug Fixes -* **deps:** cliui, find-up, and string-width, all drop Node 6 support ([#1479](https://www.github.com/yargs/yargs/issues/1479)) ([6a9ebe2](https://www.github.com/yargs/yargs/commit/6a9ebe2d955e3e979e76c07ffbb1c17fef64cb49)) +- **deps:** cliui, find-up, and string-width, all drop Node 6 support ([#1479](https://www.github.com/yargs/yargs/issues/1479)) ([6a9ebe2](https://www.github.com/yargs/yargs/commit/6a9ebe2d955e3e979e76c07ffbb1c17fef64cb49)) ## [15.0.0](https://www.github.com/yargs/yargs/compare/v14.2.0...v15.0.0) (2019-11-10) - ### ⚠ BREAKING CHANGES -* **deps:** yargs-parser now throws on invalid combinations of config (#1470) -* yargs-parser@16.0.0 drops support for Node 6 -* drop Node 6 support (#1461) -* remove package.json-based parserConfiguration (#1460) +- **deps:** yargs-parser now throws on invalid combinations of config (#1470) +- yargs-parser@16.0.0 drops support for Node 6 +- drop Node 6 support (#1461) +- remove package.json-based parserConfiguration (#1460) ### Features -* **deps:** yargs-parser now throws on invalid combinations of config ([#1470](https://www.github.com/yargs/yargs/issues/1470)) ([c10c38c](https://www.github.com/yargs/yargs/commit/c10c38cca04298f96b55a7e374a9a134abefffa7)) -* expose `Parser` from `require('yargs/yargs')` ([#1477](https://www.github.com/yargs/yargs/issues/1477)) ([1840ba2](https://www.github.com/yargs/yargs/commit/1840ba22f1a24c0ece8e32bbd31db4134a080aee)) - +- **deps:** yargs-parser now throws on invalid combinations of config ([#1470](https://www.github.com/yargs/yargs/issues/1470)) ([c10c38c](https://www.github.com/yargs/yargs/commit/c10c38cca04298f96b55a7e374a9a134abefffa7)) +- expose `Parser` from `require('yargs/yargs')` ([#1477](https://www.github.com/yargs/yargs/issues/1477)) ([1840ba2](https://www.github.com/yargs/yargs/commit/1840ba22f1a24c0ece8e32bbd31db4134a080aee)) ### Bug Fixes -* **docs:** -cript import to prevent a future major release warning ([#1441](https://www.github.com/yargs/yargs/issues/1441)) ([b1b156a](https://www.github.com/yargs/yargs/commit/b1b156a3eb4ddd6803fbbd56c611a77919293000)) -* stop-parse was not being respected by commands ([#1459](https://www.github.com/yargs/yargs/issues/1459)) ([12c82e6](https://www.github.com/yargs/yargs/commit/12c82e62663e928148a7ee2f51629aa26a0f9bb2)) -* update to yargs-parser with fix for array default values ([#1463](https://www.github.com/yargs/yargs/issues/1463)) ([ebee59d](https://www.github.com/yargs/yargs/commit/ebee59d9022da538410e69a5c025019ed46d13d2)) -* **docs:** update boolean description and examples in docs ([#1474](https://www.github.com/yargs/yargs/issues/1474)) ([afd5b48](https://www.github.com/yargs/yargs/commit/afd5b4871bfeb90d58351ac56c5c44a83ef033e6)) - +- **docs:** + cript import to prevent a future major release warning ([#1441](https://www.github.com/yargs/yargs/issues/1441)) ([b1b156a](https://www.github.com/yargs/yargs/commit/b1b156a3eb4ddd6803fbbd56c611a77919293000)) +- stop-parse was not being respected by commands ([#1459](https://www.github.com/yargs/yargs/issues/1459)) ([12c82e6](https://www.github.com/yargs/yargs/commit/12c82e62663e928148a7ee2f51629aa26a0f9bb2)) +- update to yargs-parser with fix for array default values ([#1463](https://www.github.com/yargs/yargs/issues/1463)) ([ebee59d](https://www.github.com/yargs/yargs/commit/ebee59d9022da538410e69a5c025019ed46d13d2)) +- **docs:** update boolean description and examples in docs ([#1474](https://www.github.com/yargs/yargs/issues/1474)) ([afd5b48](https://www.github.com/yargs/yargs/commit/afd5b4871bfeb90d58351ac56c5c44a83ef033e6)) ### Miscellaneous Chores -* drop Node 6 support ([#1461](https://www.github.com/yargs/yargs/issues/1461)) ([2ba8ce0](https://www.github.com/yargs/yargs/commit/2ba8ce05e8fefbeffc6cb7488d9ebf6e86cceb1d)) - +- drop Node 6 support ([#1461](https://www.github.com/yargs/yargs/issues/1461)) ([2ba8ce0](https://www.github.com/yargs/yargs/commit/2ba8ce05e8fefbeffc6cb7488d9ebf6e86cceb1d)) ### Code Refactoring -* remove package.json-based parserConfiguration ([#1460](https://www.github.com/yargs/yargs/issues/1460)) ([0d3642b](https://www.github.com/yargs/yargs/commit/0d3642b6f829b637938774c0c6ce5f6bfe1afa51)) +- remove package.json-based parserConfiguration ([#1460](https://www.github.com/yargs/yargs/issues/1460)) ([0d3642b](https://www.github.com/yargs/yargs/commit/0d3642b6f829b637938774c0c6ce5f6bfe1afa51)) ## [14.2.0](https://github.com/yargs/yargs/compare/v14.1.0...v14.2.0) (2019-10-07) - ### Bug Fixes -* async middleware was called twice ([#1422](https://github.com/yargs/yargs/issues/1422)) ([9a42b63](https://github.com/yargs/yargs/commit/9a42b63)) -* fix promise check to accept any spec conform object ([#1424](https://github.com/yargs/yargs/issues/1424)) ([0be43d2](https://github.com/yargs/yargs/commit/0be43d2)) -* groups were not being maintained for nested commands ([#1430](https://github.com/yargs/yargs/issues/1430)) ([d38650e](https://github.com/yargs/yargs/commit/d38650e)) -* **docs:** broken markdown link ([#1426](https://github.com/yargs/yargs/issues/1426)) ([236e24e](https://github.com/yargs/yargs/commit/236e24e)) -* support merging deeply nested configuration ([#1423](https://github.com/yargs/yargs/issues/1423)) ([bae66fe](https://github.com/yargs/yargs/commit/bae66fe)) - +- async middleware was called twice ([#1422](https://github.com/yargs/yargs/issues/1422)) ([9a42b63](https://github.com/yargs/yargs/commit/9a42b63)) +- fix promise check to accept any spec conform object ([#1424](https://github.com/yargs/yargs/issues/1424)) ([0be43d2](https://github.com/yargs/yargs/commit/0be43d2)) +- groups were not being maintained for nested commands ([#1430](https://github.com/yargs/yargs/issues/1430)) ([d38650e](https://github.com/yargs/yargs/commit/d38650e)) +- **docs:** broken markdown link ([#1426](https://github.com/yargs/yargs/issues/1426)) ([236e24e](https://github.com/yargs/yargs/commit/236e24e)) +- support merging deeply nested configuration ([#1423](https://github.com/yargs/yargs/issues/1423)) ([bae66fe](https://github.com/yargs/yargs/commit/bae66fe)) ### Features -* **deps:** introduce yargs-parser with support for unknown-options-as-args ([#1440](https://github.com/yargs/yargs/issues/1440)) ([4d21520](https://github.com/yargs/yargs/commit/4d21520)) +- **deps:** introduce yargs-parser with support for unknown-options-as-args ([#1440](https://github.com/yargs/yargs/issues/1440)) ([4d21520](https://github.com/yargs/yargs/commit/4d21520)) ## [14.1.0](https://github.com/yargs/yargs/compare/v14.0.0...v14.1.0) (2019-09-06) - ### Bug Fixes -* **docs:** fix incorrect parserConfiguration documentation ([2a99124](https://github.com/yargs/yargs/commit/2a99124)) -* detect zsh when zsh isnt run as a login prompt ([#1395](https://github.com/yargs/yargs/issues/1395)) ([8792d13](https://github.com/yargs/yargs/commit/8792d13)) -* populate correct value on yargs.parsed and stop warning on access ([#1412](https://github.com/yargs/yargs/issues/1412)) ([bb0eb52](https://github.com/yargs/yargs/commit/bb0eb52)) -* showCompletionScript was logging script twice ([#1388](https://github.com/yargs/yargs/issues/1388)) ([07c8537](https://github.com/yargs/yargs/commit/07c8537)) -* strict() should not ignore hyphenated arguments ([#1414](https://github.com/yargs/yargs/issues/1414)) ([b774b5e](https://github.com/yargs/yargs/commit/b774b5e)) -* **docs:** formalize existing callback argument to showHelp ([#1386](https://github.com/yargs/yargs/issues/1386)) ([d217764](https://github.com/yargs/yargs/commit/d217764)) - +- **docs:** fix incorrect parserConfiguration documentation ([2a99124](https://github.com/yargs/yargs/commit/2a99124)) +- detect zsh when zsh isnt run as a login prompt ([#1395](https://github.com/yargs/yargs/issues/1395)) ([8792d13](https://github.com/yargs/yargs/commit/8792d13)) +- populate correct value on yargs.parsed and stop warning on access ([#1412](https://github.com/yargs/yargs/issues/1412)) ([bb0eb52](https://github.com/yargs/yargs/commit/bb0eb52)) +- showCompletionScript was logging script twice ([#1388](https://github.com/yargs/yargs/issues/1388)) ([07c8537](https://github.com/yargs/yargs/commit/07c8537)) +- strict() should not ignore hyphenated arguments ([#1414](https://github.com/yargs/yargs/issues/1414)) ([b774b5e](https://github.com/yargs/yargs/commit/b774b5e)) +- **docs:** formalize existing callback argument to showHelp ([#1386](https://github.com/yargs/yargs/issues/1386)) ([d217764](https://github.com/yargs/yargs/commit/d217764)) ### Features -* make it possible to merge configurations when extending other config. ([#1411](https://github.com/yargs/yargs/issues/1411)) ([5d7ad98](https://github.com/yargs/yargs/commit/5d7ad98)) - +- make it possible to merge configurations when extending other config. ([#1411](https://github.com/yargs/yargs/issues/1411)) ([5d7ad98](https://github.com/yargs/yargs/commit/5d7ad98)) ## [14.0.0](https://github.com/yargs/yargs/compare/v13.3.0...v14.0.0) (2019-07-30) - ### ⚠ BREAKING CHANGES -* we now only officially support yargs.$0 parameter and discourage direct access to yargs.parsed -* previously to this fix methods like `yargs.getOptions()` contained the state of the last command to execute. -* do not allow additional positionals in strict mode +- we now only officially support yargs.$0 parameter and discourage direct access to yargs.parsed +- previously to this fix methods like `yargs.getOptions()` contained the state of the last command to execute. +- do not allow additional positionals in strict mode ### Bug Fixes -* calling parse multiple times now appropriately maintains state ([#1137](https://github.com/yargs/yargs/issues/1137)) ([#1369](https://github.com/yargs/yargs/issues/1369)) ([026b151](https://github.com/yargs/yargs/commit/026b151)) -* prefer user supplied script name in usage ([#1383](https://github.com/yargs/yargs/issues/1383)) ([28c74b9](https://github.com/yargs/yargs/commit/28c74b9)) -* **deps:** use decamelize from npm instead of vendored copy ([#1377](https://github.com/yargs/yargs/issues/1377)) ([015eeb9](https://github.com/yargs/yargs/commit/015eeb9)) -* **examples:** fix usage-options.js to reflect current API ([#1375](https://github.com/yargs/yargs/issues/1375)) ([6e5b76b](https://github.com/yargs/yargs/commit/6e5b76b)) -* do not allow additional positionals in strict mode ([35d777c](https://github.com/yargs/yargs/commit/35d777c)) -* properties accessed on singleton now reflect current state of instance ([#1366](https://github.com/yargs/yargs/issues/1366)) ([409d35b](https://github.com/yargs/yargs/commit/409d35b)) -* tolerate null prototype for config objects with `extends` ([#1376](https://github.com/yargs/yargs/issues/1376)) ([3d26d11](https://github.com/yargs/yargs/commit/3d26d11)), closes [#1372](https://github.com/yargs/yargs/issues/1372) -* yargs.parsed now populated before returning, when yargs.parse() called with no args (#1382) ([e3981fd](https://github.com/yargs/yargs/commit/e3981fd)), closes [#1382](https://github.com/yargs/yargs/issues/1382) +- calling parse multiple times now appropriately maintains state ([#1137](https://github.com/yargs/yargs/issues/1137)) ([#1369](https://github.com/yargs/yargs/issues/1369)) ([026b151](https://github.com/yargs/yargs/commit/026b151)) +- prefer user supplied script name in usage ([#1383](https://github.com/yargs/yargs/issues/1383)) ([28c74b9](https://github.com/yargs/yargs/commit/28c74b9)) +- **deps:** use decamelize from npm instead of vendored copy ([#1377](https://github.com/yargs/yargs/issues/1377)) ([015eeb9](https://github.com/yargs/yargs/commit/015eeb9)) +- **examples:** fix usage-options.js to reflect current API ([#1375](https://github.com/yargs/yargs/issues/1375)) ([6e5b76b](https://github.com/yargs/yargs/commit/6e5b76b)) +- do not allow additional positionals in strict mode ([35d777c](https://github.com/yargs/yargs/commit/35d777c)) +- properties accessed on singleton now reflect current state of instance ([#1366](https://github.com/yargs/yargs/issues/1366)) ([409d35b](https://github.com/yargs/yargs/commit/409d35b)) +- tolerate null prototype for config objects with `extends` ([#1376](https://github.com/yargs/yargs/issues/1376)) ([3d26d11](https://github.com/yargs/yargs/commit/3d26d11)), closes [#1372](https://github.com/yargs/yargs/issues/1372) +- yargs.parsed now populated before returning, when yargs.parse() called with no args (#1382) ([e3981fd](https://github.com/yargs/yargs/commit/e3981fd)), closes [#1382](https://github.com/yargs/yargs/issues/1382) ### Features -* adds support for multiple epilog messages ([#1384](https://github.com/yargs/yargs/issues/1384)) ([07a5554](https://github.com/yargs/yargs/commit/07a5554)) -* allow completionCommand to be set via showCompletionScript ([#1385](https://github.com/yargs/yargs/issues/1385)) ([5562853](https://github.com/yargs/yargs/commit/5562853)) +- adds support for multiple epilog messages ([#1384](https://github.com/yargs/yargs/issues/1384)) ([07a5554](https://github.com/yargs/yargs/commit/07a5554)) +- allow completionCommand to be set via showCompletionScript ([#1385](https://github.com/yargs/yargs/issues/1385)) ([5562853](https://github.com/yargs/yargs/commit/5562853)) ## [13.3.0](https://www.github.com/yargs/yargs/compare/v13.2.4...v13.3.0) (2019-06-10) - ### Bug Fixes -* **deps:** yargs-parser update addressing several parsing bugs ([#1357](https://www.github.com/yargs/yargs/issues/1357)) ([e230d5b](https://www.github.com/yargs/yargs/commit/e230d5b)) - +- **deps:** yargs-parser update addressing several parsing bugs ([#1357](https://www.github.com/yargs/yargs/issues/1357)) ([e230d5b](https://www.github.com/yargs/yargs/commit/e230d5b)) ### Features -* **i18n:** swap out os-locale dependency for simple inline implementation ([#1356](https://www.github.com/yargs/yargs/issues/1356)) ([4dfa19b](https://www.github.com/yargs/yargs/commit/4dfa19b)) -* support defaultDescription for positional arguments ([812048c](https://www.github.com/yargs/yargs/commit/812048c)) +- **i18n:** swap out os-locale dependency for simple inline implementation ([#1356](https://www.github.com/yargs/yargs/issues/1356)) ([4dfa19b](https://www.github.com/yargs/yargs/commit/4dfa19b)) +- support defaultDescription for positional arguments ([812048c](https://www.github.com/yargs/yargs/commit/812048c)) ### [13.2.4](https://github.com/yargs/yargs/compare/v13.2.3...v13.2.4) (2019-05-13) - ### Bug Fixes -* **i18n:** rename unclear 'implication failed' to 'missing dependent arguments' ([#1317](https://github.com/yargs/yargs/issues/1317)) ([bf46813](https://github.com/yargs/yargs/commit/bf46813)) - - +- **i18n:** rename unclear 'implication failed' to 'missing dependent arguments' ([#1317](https://github.com/yargs/yargs/issues/1317)) ([bf46813](https://github.com/yargs/yargs/commit/bf46813)) ### [13.2.3](https://github.com/yargs/yargs/compare/v13.2.2...v13.2.3) (2019-05-05) - ### Bug Fixes -* **deps:** upgrade cliui for compatibility with latest chalk. ([#1330](https://github.com/yargs/yargs/issues/1330)) ([b20db65](https://github.com/yargs/yargs/commit/b20db65)) -* address issues with dutch translation ([#1316](https://github.com/yargs/yargs/issues/1316)) ([0295132](https://github.com/yargs/yargs/commit/0295132)) - +- **deps:** upgrade cliui for compatibility with latest chalk. ([#1330](https://github.com/yargs/yargs/issues/1330)) ([b20db65](https://github.com/yargs/yargs/commit/b20db65)) +- address issues with dutch translation ([#1316](https://github.com/yargs/yargs/issues/1316)) ([0295132](https://github.com/yargs/yargs/commit/0295132)) ### Tests -* accept differently formatted output ([#1327](https://github.com/yargs/yargs/issues/1327)) ([c294d1b](https://github.com/yargs/yargs/commit/c294d1b)) - - +- accept differently formatted output ([#1327](https://github.com/yargs/yargs/issues/1327)) ([c294d1b](https://github.com/yargs/yargs/commit/c294d1b)) ## [13.2.2](https://github.com/yargs/yargs/compare/v13.2.1...v13.2.2) (2019-03-06) - - ## [13.2.1](https://github.com/yargs/yargs/compare/v13.2.0...v13.2.1) (2019-02-18) - ### Bug Fixes -* add zsh script to files array ([3180224](https://github.com/yargs/yargs/commit/3180224)) -* support options/sub-commands in zsh completion ([0a96394](https://github.com/yargs/yargs/commit/0a96394)) - +- add zsh script to files array ([3180224](https://github.com/yargs/yargs/commit/3180224)) +- support options/sub-commands in zsh completion ([0a96394](https://github.com/yargs/yargs/commit/0a96394)) # [13.2.0](https://github.com/yargs/yargs/compare/v13.1.0...v13.2.0) (2019-02-15) - ### Features -* zsh auto completion ([#1292](https://github.com/yargs/yargs/issues/1292)) ([16c5d25](https://github.com/yargs/yargs/commit/16c5d25)), closes [#1156](https://github.com/yargs/yargs/issues/1156) - +- zsh auto completion ([#1292](https://github.com/yargs/yargs/issues/1292)) ([16c5d25](https://github.com/yargs/yargs/commit/16c5d25)), closes [#1156](https://github.com/yargs/yargs/issues/1156) -# [13.1.0](https://github.com/yargs/yargs/compare/v13.0.0...v13.1.0) (2019-02-12) +# [13.1.0](https://github.com/yargs/yargs/compare/v13.0.0...v13.1.0) (2019-02-12) ### Features -* add applyBeforeValidation, for applying sync middleware before validation ([5be206a](https://github.com/yargs/yargs/commit/5be206a)) - - +- add applyBeforeValidation, for applying sync middleware before validation ([5be206a](https://github.com/yargs/yargs/commit/5be206a)) -# [13.0.0](https://github.com/yargs/yargs/compare/v12.0.5...v13.0.0) (2019-02-02) +# [13.0.0](https://github.com/yargs/yargs/compare/v12.0.5...v13.0.0) (2019-02-02) ### Bug Fixes -* **deps:** Update os-locale to avoid security vulnerability ([#1270](https://github.com/yargs/yargs/issues/1270)) ([27bf739](https://github.com/yargs/yargs/commit/27bf739)) -* **validation:** Use the error as a message when none exists otherwise ([#1268](https://github.com/yargs/yargs/issues/1268)) ([0510fe6](https://github.com/yargs/yargs/commit/0510fe6)) -* better bash path completion ([#1272](https://github.com/yargs/yargs/issues/1272)) ([da75ea2](https://github.com/yargs/yargs/commit/da75ea2)) -* middleware added multiple times due to reference bug ([#1282](https://github.com/yargs/yargs/issues/1282)) ([64af518](https://github.com/yargs/yargs/commit/64af518)) - +- **deps:** Update os-locale to avoid security vulnerability ([#1270](https://github.com/yargs/yargs/issues/1270)) ([27bf739](https://github.com/yargs/yargs/commit/27bf739)) +- **validation:** Use the error as a message when none exists otherwise ([#1268](https://github.com/yargs/yargs/issues/1268)) ([0510fe6](https://github.com/yargs/yargs/commit/0510fe6)) +- better bash path completion ([#1272](https://github.com/yargs/yargs/issues/1272)) ([da75ea2](https://github.com/yargs/yargs/commit/da75ea2)) +- middleware added multiple times due to reference bug ([#1282](https://github.com/yargs/yargs/issues/1282)) ([64af518](https://github.com/yargs/yargs/commit/64af518)) ### Chores -* ~drop Node 6 from testing matrix ([#1287](https://github.com/yargs/yargs/issues/1287)) ([ef16792](https://github.com/yargs/yargs/commit/ef16792))~ - * _opting to not drop Node 6 support until April, [see](https://github.com/nodejs/Release)._ -* update dependencies ([#1284](https://github.com/yargs/yargs/issues/1284)) ([f25de4f](https://github.com/yargs/yargs/commit/f25de4f)) - +- ~drop Node 6 from testing matrix ([#1287](https://github.com/yargs/yargs/issues/1287)) ([ef16792](https://github.com/yargs/yargs/commit/ef16792))~ + - _opting to not drop Node 6 support until April, [see](https://github.com/nodejs/Release)._ +- update dependencies ([#1284](https://github.com/yargs/yargs/issues/1284)) ([f25de4f](https://github.com/yargs/yargs/commit/f25de4f)) ### Features -* Add `.parserConfiguration()` method, deprecating package.json config ([#1262](https://github.com/yargs/yargs/issues/1262)) ([3c6869a](https://github.com/yargs/yargs/commit/3c6869a)) -* adds config option for sorting command output ([#1256](https://github.com/yargs/yargs/issues/1256)) ([6916ce9](https://github.com/yargs/yargs/commit/6916ce9)) -* options/positionals with leading '+' and '0' no longer parse as numbers ([#1286](https://github.com/yargs/yargs/issues/1286)) ([e9dc3aa](https://github.com/yargs/yargs/commit/e9dc3aa)) -* support promises in middleware ([f3a4e4f](https://github.com/yargs/yargs/commit/f3a4e4f)) - +- Add `.parserConfiguration()` method, deprecating package.json config ([#1262](https://github.com/yargs/yargs/issues/1262)) ([3c6869a](https://github.com/yargs/yargs/commit/3c6869a)) +- adds config option for sorting command output ([#1256](https://github.com/yargs/yargs/issues/1256)) ([6916ce9](https://github.com/yargs/yargs/commit/6916ce9)) +- options/positionals with leading '+' and '0' no longer parse as numbers ([#1286](https://github.com/yargs/yargs/issues/1286)) ([e9dc3aa](https://github.com/yargs/yargs/commit/e9dc3aa)) +- support promises in middleware ([f3a4e4f](https://github.com/yargs/yargs/commit/f3a4e4f)) ### BREAKING CHANGES -* options with leading '+' or '0' now parse as strings -* dropping Node 6 which hits end of life in April 2019 -* see [yargs-parser@12.0.0 CHANGELOG](https://github.com/yargs/yargs-parser/blob/main/CHANGELOG.md#breaking-changes) -* we now warn if the yargs stanza package.json is used. +- options with leading '+' or '0' now parse as strings +- dropping Node 6 which hits end of life in April 2019 +- see [yargs-parser@12.0.0 CHANGELOG](https://github.com/yargs/yargs-parser/blob/main/CHANGELOG.md#breaking-changes) +- we now warn if the yargs stanza package.json is used. -## [12.0.5](https://github.com/yargs/yargs/compare/v12.0.4...v12.0.5) (2018-11-19) +## [12.0.5](https://github.com/yargs/yargs/compare/v12.0.4...v12.0.5) (2018-11-19) ### Bug Fixes -* allows camel-case, variadic arguments, and strict mode to be combined ([#1247](https://github.com/yargs/yargs/issues/1247)) ([eacc035](https://github.com/yargs/yargs/commit/eacc035)) - - +- allows camel-case, variadic arguments, and strict mode to be combined ([#1247](https://github.com/yargs/yargs/issues/1247)) ([eacc035](https://github.com/yargs/yargs/commit/eacc035)) -## [12.0.4](https://github.com/yargs/yargs/compare/v12.0.3...v12.0.4) (2018-11-10) +## [12.0.4](https://github.com/yargs/yargs/compare/v12.0.3...v12.0.4) (2018-11-10) ### Bug Fixes -* don't load config when processing positionals ([5d0dc92](https://github.com/yargs/yargs/commit/5d0dc92)) - - +- don't load config when processing positionals ([5d0dc92](https://github.com/yargs/yargs/commit/5d0dc92)) -## [12.0.3](https://github.com/yargs/yargs/compare/v12.0.2...v12.0.3) (2018-10-06) +## [12.0.3](https://github.com/yargs/yargs/compare/v12.0.2...v12.0.3) (2018-10-06) ### Bug Fixes -* $0 contains first arg in bundled electron apps ([#1206](https://github.com/yargs/yargs/issues/1206)) ([567820b](https://github.com/yargs/yargs/commit/567820b)) -* accept single function for middleware ([66fd6f7](https://github.com/yargs/yargs/commit/66fd6f7)), closes [#1214](https://github.com/yargs/yargs/issues/1214) [#1214](https://github.com/yargs/yargs/issues/1214) -* hide `hidden` options from help output even if they are in a group ([#1221](https://github.com/yargs/yargs/issues/1221)) ([da54028](https://github.com/yargs/yargs/commit/da54028)) -* improve Norwegian Bokmål translations ([#1208](https://github.com/yargs/yargs/issues/1208)) ([a458fa4](https://github.com/yargs/yargs/commit/a458fa4)) -* improve Norwegian Nynorsk translations ([#1207](https://github.com/yargs/yargs/issues/1207)) ([d422eb5](https://github.com/yargs/yargs/commit/d422eb5)) - - +- $0 contains first arg in bundled electron apps ([#1206](https://github.com/yargs/yargs/issues/1206)) ([567820b](https://github.com/yargs/yargs/commit/567820b)) +- accept single function for middleware ([66fd6f7](https://github.com/yargs/yargs/commit/66fd6f7)), closes [#1214](https://github.com/yargs/yargs/issues/1214) [#1214](https://github.com/yargs/yargs/issues/1214) +- hide `hidden` options from help output even if they are in a group ([#1221](https://github.com/yargs/yargs/issues/1221)) ([da54028](https://github.com/yargs/yargs/commit/da54028)) +- improve Norwegian Bokmål translations ([#1208](https://github.com/yargs/yargs/issues/1208)) ([a458fa4](https://github.com/yargs/yargs/commit/a458fa4)) +- improve Norwegian Nynorsk translations ([#1207](https://github.com/yargs/yargs/issues/1207)) ([d422eb5](https://github.com/yargs/yargs/commit/d422eb5)) -## [12.0.2](https://github.com/yargs/yargs/compare/v12.0.1...v12.0.2) (2018-09-04) +## [12.0.2](https://github.com/yargs/yargs/compare/v12.0.1...v12.0.2) (2018-09-04) ### Bug Fixes -* middleware should work regardless of when method is called ([664b265](https://github.com/yargs/yargs/commit/664b265)), closes [#1178](https://github.com/yargs/yargs/issues/1178) -* translation not working when using __ with a single parameter ([#1183](https://github.com/yargs/yargs/issues/1183)) ([f449aea](https://github.com/yargs/yargs/commit/f449aea)) -* upgrade os-locale to version that addresses license issue ([#1195](https://github.com/yargs/yargs/issues/1195)) ([efc0970](https://github.com/yargs/yargs/commit/efc0970)) - - +- middleware should work regardless of when method is called ([664b265](https://github.com/yargs/yargs/commit/664b265)), closes [#1178](https://github.com/yargs/yargs/issues/1178) +- translation not working when using \_\_ with a single parameter ([#1183](https://github.com/yargs/yargs/issues/1183)) ([f449aea](https://github.com/yargs/yargs/commit/f449aea)) +- upgrade os-locale to version that addresses license issue ([#1195](https://github.com/yargs/yargs/issues/1195)) ([efc0970](https://github.com/yargs/yargs/commit/efc0970)) -## [12.0.1](https://github.com/yargs/yargs/compare/v12.0.0...v12.0.1) (2018-06-29) - +## [12.0.1](https://github.com/yargs/yargs/compare/v12.0.0...v12.0.1) (2018-06-29) -# [12.0.0](https://github.com/yargs/yargs/compare/v11.1.0...v12.0.0) (2018-06-26) +# [12.0.0](https://github.com/yargs/yargs/compare/v11.1.0...v12.0.0) (2018-06-26) ### Bug Fixes -* .argv and .parse() now invoke identical code path ([#1126](https://github.com/yargs/yargs/issues/1126)) ([f13ebf4](https://github.com/yargs/yargs/commit/f13ebf4)) -* remove the trailing white spaces from the help output ([#1090](https://github.com/yargs/yargs/issues/1090)) ([3f0746c](https://github.com/yargs/yargs/commit/3f0746c)) -* **completion:** Avoid default command and recommendations during completion ([#1123](https://github.com/yargs/yargs/issues/1123)) ([036e7c5](https://github.com/yargs/yargs/commit/036e7c5)) - +- .argv and .parse() now invoke identical code path ([#1126](https://github.com/yargs/yargs/issues/1126)) ([f13ebf4](https://github.com/yargs/yargs/commit/f13ebf4)) +- remove the trailing white spaces from the help output ([#1090](https://github.com/yargs/yargs/issues/1090)) ([3f0746c](https://github.com/yargs/yargs/commit/3f0746c)) +- **completion:** Avoid default command and recommendations during completion ([#1123](https://github.com/yargs/yargs/issues/1123)) ([036e7c5](https://github.com/yargs/yargs/commit/036e7c5)) ### Chores -* test Node.js 6, 8 and 10 ([#1160](https://github.com/yargs/yargs/issues/1160)) ([84f9d2b](https://github.com/yargs/yargs/commit/84f9d2b)) -* upgrade to version of yargs-parser that does not populate value for unset boolean ([#1104](https://github.com/yargs/yargs/issues/1104)) ([d4705f4](https://github.com/yargs/yargs/commit/d4705f4)) - +- test Node.js 6, 8 and 10 ([#1160](https://github.com/yargs/yargs/issues/1160)) ([84f9d2b](https://github.com/yargs/yargs/commit/84f9d2b)) +- upgrade to version of yargs-parser that does not populate value for unset boolean ([#1104](https://github.com/yargs/yargs/issues/1104)) ([d4705f4](https://github.com/yargs/yargs/commit/d4705f4)) ### Features -* add support for global middleware, useful for shared tasks like metrics ([#1119](https://github.com/yargs/yargs/issues/1119)) ([9d71ac7](https://github.com/yargs/yargs/commit/9d71ac7)) -* allow setting scriptName $0 ([#1143](https://github.com/yargs/yargs/issues/1143)) ([a2f2eae](https://github.com/yargs/yargs/commit/a2f2eae)) -* remove `setPlaceholderKeys` ([#1105](https://github.com/yargs/yargs/issues/1105)) ([6ee2c82](https://github.com/yargs/yargs/commit/6ee2c82)) - +- add support for global middleware, useful for shared tasks like metrics ([#1119](https://github.com/yargs/yargs/issues/1119)) ([9d71ac7](https://github.com/yargs/yargs/commit/9d71ac7)) +- allow setting scriptName $0 ([#1143](https://github.com/yargs/yargs/issues/1143)) ([a2f2eae](https://github.com/yargs/yargs/commit/a2f2eae)) +- remove `setPlaceholderKeys` ([#1105](https://github.com/yargs/yargs/issues/1105)) ([6ee2c82](https://github.com/yargs/yargs/commit/6ee2c82)) ### BREAKING CHANGES -* Options absent from `argv` (not set via CLI argument) are now absent from the parsed result object rather than being set with `undefined` -* drop Node 4 from testing matrix, such that we'll gradually start drifting away from supporting Node 4. -* yargs-parser does not populate 'false' when boolean flag is not passed -* tests that assert against help output will need to be updated - - +- Options absent from `argv` (not set via CLI argument) are now absent from the parsed result object rather than being set with `undefined` +- drop Node 4 from testing matrix, such that we'll gradually start drifting away from supporting Node 4. +- yargs-parser does not populate 'false' when boolean flag is not passed +- tests that assert against help output will need to be updated -# [11.1.0](https://github.com/yargs/yargs/compare/v11.0.0...v11.1.0) (2018-03-04) +# [11.1.0](https://github.com/yargs/yargs/compare/v11.0.0...v11.1.0) (2018-03-04) ### Bug Fixes -* choose correct config directory when require.main does not exist ([#1056](https://github.com/yargs/yargs/issues/1056)) ([a04678c](https://github.com/yargs/yargs/commit/a04678c)) - +- choose correct config directory when require.main does not exist ([#1056](https://github.com/yargs/yargs/issues/1056)) ([a04678c](https://github.com/yargs/yargs/commit/a04678c)) ### Features -* allow hidden options to be displayed with --show-hidden ([#1061](https://github.com/yargs/yargs/issues/1061)) ([ea862ae](https://github.com/yargs/yargs/commit/ea862ae)) -* extend *.rc files in addition to json ([#1080](https://github.com/yargs/yargs/issues/1080)) ([11691a6](https://github.com/yargs/yargs/commit/11691a6)) - - +- allow hidden options to be displayed with --show-hidden ([#1061](https://github.com/yargs/yargs/issues/1061)) ([ea862ae](https://github.com/yargs/yargs/commit/ea862ae)) +- extend \*.rc files in addition to json ([#1080](https://github.com/yargs/yargs/issues/1080)) ([11691a6](https://github.com/yargs/yargs/commit/11691a6)) -# [11.0.0](https://github.com/yargs/yargs/compare/v10.1.2...v11.0.0) (2018-01-22) +# [11.0.0](https://github.com/yargs/yargs/compare/v10.1.2...v11.0.0) (2018-01-22) ### Bug Fixes -* Set implicit nargs=1 when type=number requiresArg=true ([#1050](https://github.com/yargs/yargs/issues/1050)) ([2b56812](https://github.com/yargs/yargs/commit/2b56812)) - +- Set implicit nargs=1 when type=number requiresArg=true ([#1050](https://github.com/yargs/yargs/issues/1050)) ([2b56812](https://github.com/yargs/yargs/commit/2b56812)) ### Features -* requiresArg is now simply an alias for nargs(1) ([#1054](https://github.com/yargs/yargs/issues/1054)) ([a3ddacc](https://github.com/yargs/yargs/commit/a3ddacc)) - +- requiresArg is now simply an alias for nargs(1) ([#1054](https://github.com/yargs/yargs/issues/1054)) ([a3ddacc](https://github.com/yargs/yargs/commit/a3ddacc)) ### BREAKING CHANGES -* requiresArg now has significantly different error output, matching nargs. +- requiresArg now has significantly different error output, matching nargs. [Historical Versions](/docs/CHANGELOG-historical.md) -## [10.1.2](https://github.com/yargs/yargs/compare/v10.1.1...v10.1.2) (2018-01-17) +## [10.1.2](https://github.com/yargs/yargs/compare/v10.1.1...v10.1.2) (2018-01-17) ### Bug Fixes -* requiresArg should only be enforced if argument exists ([#1043](https://github.com/yargs/yargs/issues/1043)) ([fbf41ae](https://github.com/yargs/yargs/commit/fbf41ae)) - - +- requiresArg should only be enforced if argument exists ([#1043](https://github.com/yargs/yargs/issues/1043)) ([fbf41ae](https://github.com/yargs/yargs/commit/fbf41ae)) -## [10.1.1](https://github.com/yargs/yargs/compare/v10.1.0...v10.1.1) (2018-01-09) +## [10.1.1](https://github.com/yargs/yargs/compare/v10.1.0...v10.1.1) (2018-01-09) ### Bug Fixes -* Add `dirname` sanity check on `findUp` ([#1036](https://github.com/yargs/yargs/issues/1036)) ([331d103](https://github.com/yargs/yargs/commit/331d103)) - - +- Add `dirname` sanity check on `findUp` ([#1036](https://github.com/yargs/yargs/issues/1036)) ([331d103](https://github.com/yargs/yargs/commit/331d103)) -# [10.1.0](https://github.com/yargs/yargs/compare/v10.0.3...v10.1.0) (2018-01-01) +# [10.1.0](https://github.com/yargs/yargs/compare/v10.0.3...v10.1.0) (2018-01-01) ### Bug Fixes -* 'undefined' should be taken to mean no argument was provided ([#1015](https://github.com/yargs/yargs/issues/1015)) ([c679e90](https://github.com/yargs/yargs/commit/c679e90)) - +- 'undefined' should be taken to mean no argument was provided ([#1015](https://github.com/yargs/yargs/issues/1015)) ([c679e90](https://github.com/yargs/yargs/commit/c679e90)) ### Features -* add missing simple chinese locale strings ([#1004](https://github.com/yargs/yargs/issues/1004)) ([3cc24ec](https://github.com/yargs/yargs/commit/3cc24ec)) -* add Norwegian Nynorsk translations ([#1028](https://github.com/yargs/yargs/issues/1028)) ([a5ac213](https://github.com/yargs/yargs/commit/a5ac213)) -* async command handlers ([#1001](https://github.com/yargs/yargs/issues/1001)) ([241124b](https://github.com/yargs/yargs/commit/241124b)) -* middleware ([#881](https://github.com/yargs/yargs/issues/881)) ([77b8dbc](https://github.com/yargs/yargs/commit/77b8dbc)) - - +- add missing simple chinese locale strings ([#1004](https://github.com/yargs/yargs/issues/1004)) ([3cc24ec](https://github.com/yargs/yargs/commit/3cc24ec)) +- add Norwegian Nynorsk translations ([#1028](https://github.com/yargs/yargs/issues/1028)) ([a5ac213](https://github.com/yargs/yargs/commit/a5ac213)) +- async command handlers ([#1001](https://github.com/yargs/yargs/issues/1001)) ([241124b](https://github.com/yargs/yargs/commit/241124b)) +- middleware ([#881](https://github.com/yargs/yargs/issues/881)) ([77b8dbc](https://github.com/yargs/yargs/commit/77b8dbc)) -## [10.0.3](https://github.com/yargs/yargs/compare/v10.0.2...v10.0.3) (2017-10-21) +## [10.0.3](https://github.com/yargs/yargs/compare/v10.0.2...v10.0.3) (2017-10-21) ### Bug Fixes -* parse array rather than string, so that quotes are safe ([#993](https://github.com/yargs/yargs/issues/993)) ([c351685](https://github.com/yargs/yargs/commit/c351685)) - - +- parse array rather than string, so that quotes are safe ([#993](https://github.com/yargs/yargs/issues/993)) ([c351685](https://github.com/yargs/yargs/commit/c351685)) -## [10.0.2](https://github.com/yargs/yargs/compare/v10.0.1...v10.0.2) (2017-10-21) +## [10.0.2](https://github.com/yargs/yargs/compare/v10.0.1...v10.0.2) (2017-10-21) ### Bug Fixes -* fix tiny spacing issue with usage ([#992](https://github.com/yargs/yargs/issues/992)) ([7871327](https://github.com/yargs/yargs/commit/7871327)) - - +- fix tiny spacing issue with usage ([#992](https://github.com/yargs/yargs/issues/992)) ([7871327](https://github.com/yargs/yargs/commit/7871327)) -## [10.0.1](https://github.com/yargs/yargs/compare/v10.0.0...v10.0.1) (2017-10-19) +## [10.0.1](https://github.com/yargs/yargs/compare/v10.0.0...v10.0.1) (2017-10-19) ### Bug Fixes -* help strings for nested commands were missing parent commands ([#990](https://github.com/yargs/yargs/issues/990)) ([cd1ca15](https://github.com/yargs/yargs/commit/cd1ca15)) -* use correct completion command in generated completion script ([#988](https://github.com/yargs/yargs/issues/988)) ([3c8ac1d](https://github.com/yargs/yargs/commit/3c8ac1d)) - - +- help strings for nested commands were missing parent commands ([#990](https://github.com/yargs/yargs/issues/990)) ([cd1ca15](https://github.com/yargs/yargs/commit/cd1ca15)) +- use correct completion command in generated completion script ([#988](https://github.com/yargs/yargs/issues/988)) ([3c8ac1d](https://github.com/yargs/yargs/commit/3c8ac1d)) -# [10.0.0](https://github.com/yargs/yargs/compare/v9.1.0...v10.0.0) (2017-10-18) +# [10.0.0](https://github.com/yargs/yargs/compare/v9.1.0...v10.0.0) (2017-10-18) ### Bug Fixes -* config and normalize can be disabled with false ([#952](https://github.com/yargs/yargs/issues/952)) ([3bb8771](https://github.com/yargs/yargs/commit/3bb8771)) -* less eager help command execution ([#972](https://github.com/yargs/yargs/issues/972)) ([8c1d7bf](https://github.com/yargs/yargs/commit/8c1d7bf)) -* the positional argument parse was clobbering global flag arguments ([#984](https://github.com/yargs/yargs/issues/984)) ([7e58453](https://github.com/yargs/yargs/commit/7e58453)) - +- config and normalize can be disabled with false ([#952](https://github.com/yargs/yargs/issues/952)) ([3bb8771](https://github.com/yargs/yargs/commit/3bb8771)) +- less eager help command execution ([#972](https://github.com/yargs/yargs/issues/972)) ([8c1d7bf](https://github.com/yargs/yargs/commit/8c1d7bf)) +- the positional argument parse was clobbering global flag arguments ([#984](https://github.com/yargs/yargs/issues/984)) ([7e58453](https://github.com/yargs/yargs/commit/7e58453)) ### Features -* .usage() can now be used to configure a default command ([#975](https://github.com/yargs/yargs/issues/975)) ([7269531](https://github.com/yargs/yargs/commit/7269531)) -* hidden options are now explicitly indicated using "hidden" flag ([#962](https://github.com/yargs/yargs/issues/962)) ([280d0d6](https://github.com/yargs/yargs/commit/280d0d6)) -* introduce .positional() for configuring positional arguments ([#967](https://github.com/yargs/yargs/issues/967)) ([cb16460](https://github.com/yargs/yargs/commit/cb16460)) -* replace $0 with file basename ([#983](https://github.com/yargs/yargs/issues/983)) ([20bb99b](https://github.com/yargs/yargs/commit/20bb99b)) - +- .usage() can now be used to configure a default command ([#975](https://github.com/yargs/yargs/issues/975)) ([7269531](https://github.com/yargs/yargs/commit/7269531)) +- hidden options are now explicitly indicated using "hidden" flag ([#962](https://github.com/yargs/yargs/issues/962)) ([280d0d6](https://github.com/yargs/yargs/commit/280d0d6)) +- introduce .positional() for configuring positional arguments ([#967](https://github.com/yargs/yargs/issues/967)) ([cb16460](https://github.com/yargs/yargs/commit/cb16460)) +- replace $0 with file basename ([#983](https://github.com/yargs/yargs/issues/983)) ([20bb99b](https://github.com/yargs/yargs/commit/20bb99b)) ### BREAKING CHANGES -* .usage() no longer accepts an options object as the second argument. It can instead be used as an alias for configuring a default command. -* previously hidden options were simply implied using a falsy description -* help command now only executes if it's the last positional in argv._ - - +- .usage() no longer accepts an options object as the second argument. It can instead be used as an alias for configuring a default command. +- previously hidden options were simply implied using a falsy description +- help command now only executes if it's the last positional in argv.\_ -# [9.1.0](https://github.com/yargs/yargs/compare/v9.0.1...v9.1.0) (2017-09-25) +# [9.1.0](https://github.com/yargs/yargs/compare/v9.0.1...v9.1.0) (2017-09-25) ### Bug Fixes -* **command:** Run default cmd even if the only cmd ([#950](https://github.com/yargs/yargs/issues/950)) ([7b22203](https://github.com/yargs/yargs/commit/7b22203)) - +- **command:** Run default cmd even if the only cmd ([#950](https://github.com/yargs/yargs/issues/950)) ([7b22203](https://github.com/yargs/yargs/commit/7b22203)) ### Features -* multiple usage calls are now collected, not replaced ([#958](https://github.com/yargs/yargs/issues/958)) ([74a38b2](https://github.com/yargs/yargs/commit/74a38b2)) - - +- multiple usage calls are now collected, not replaced ([#958](https://github.com/yargs/yargs/issues/958)) ([74a38b2](https://github.com/yargs/yargs/commit/74a38b2)) -## [9.0.1](https://github.com/yargs/yargs/compare/v9.0.0...v9.0.1) (2017-09-17) +## [9.0.1](https://github.com/yargs/yargs/compare/v9.0.0...v9.0.1) (2017-09-17) ### Bug Fixes -* implications fails only displayed once ([#954](https://github.com/yargs/yargs/issues/954)) ([ac8088b](https://github.com/yargs/yargs/commit/ac8088b)) - - +- implications fails only displayed once ([#954](https://github.com/yargs/yargs/issues/954)) ([ac8088b](https://github.com/yargs/yargs/commit/ac8088b)) -# [9.0.0](https://github.com/yargs/yargs/compare/v8.0.2...v9.0.0) (2017-09-03) +# [9.0.0](https://github.com/yargs/yargs/compare/v8.0.2...v9.0.0) (2017-09-03) ### Bug Fixes -* 'undefined' default value for choices resulted in validation failing ([782b896](https://github.com/yargs/yargs/commit/782b896)) -* address bug with handling of arrays of implications ([c240661](https://github.com/yargs/yargs/commit/c240661)) -* defaulting keys to 'undefined' interfered with conflicting key logic ([a8e0cff](https://github.com/yargs/yargs/commit/a8e0cff)) -* don't bother calling JSON.stringify() on string default values ([#891](https://github.com/yargs/yargs/issues/891)) ([628be21](https://github.com/yargs/yargs/commit/628be21)) -* exclude positional arguments from completion output ([#927](https://github.com/yargs/yargs/issues/927)) ([71c7ec7](https://github.com/yargs/yargs/commit/71c7ec7)) -* strict mode should not fail for hidden options ([#949](https://github.com/yargs/yargs/issues/949)) ([0e0c58d](https://github.com/yargs/yargs/commit/0e0c58d)) - +- 'undefined' default value for choices resulted in validation failing ([782b896](https://github.com/yargs/yargs/commit/782b896)) +- address bug with handling of arrays of implications ([c240661](https://github.com/yargs/yargs/commit/c240661)) +- defaulting keys to 'undefined' interfered with conflicting key logic ([a8e0cff](https://github.com/yargs/yargs/commit/a8e0cff)) +- don't bother calling JSON.stringify() on string default values ([#891](https://github.com/yargs/yargs/issues/891)) ([628be21](https://github.com/yargs/yargs/commit/628be21)) +- exclude positional arguments from completion output ([#927](https://github.com/yargs/yargs/issues/927)) ([71c7ec7](https://github.com/yargs/yargs/commit/71c7ec7)) +- strict mode should not fail for hidden options ([#949](https://github.com/yargs/yargs/issues/949)) ([0e0c58d](https://github.com/yargs/yargs/commit/0e0c58d)) ### Features -* allow implies and conflicts to accept array values ([#922](https://github.com/yargs/yargs/issues/922)) ([abdc7da](https://github.com/yargs/yargs/commit/abdc7da)) -* allow parse with no arguments as alias for yargs.argv ([#944](https://github.com/yargs/yargs/issues/944)) ([a9f03e7](https://github.com/yargs/yargs/commit/a9f03e7)) -* enable .help() and .version() by default ([#912](https://github.com/yargs/yargs/issues/912)) ([1ef44e0](https://github.com/yargs/yargs/commit/1ef44e0)) -* to allow both undefined and nulls, for benefit of TypeScript ([#945](https://github.com/yargs/yargs/issues/945)) ([792564d](https://github.com/yargs/yargs/commit/792564d)) - +- allow implies and conflicts to accept array values ([#922](https://github.com/yargs/yargs/issues/922)) ([abdc7da](https://github.com/yargs/yargs/commit/abdc7da)) +- allow parse with no arguments as alias for yargs.argv ([#944](https://github.com/yargs/yargs/issues/944)) ([a9f03e7](https://github.com/yargs/yargs/commit/a9f03e7)) +- enable .help() and .version() by default ([#912](https://github.com/yargs/yargs/issues/912)) ([1ef44e0](https://github.com/yargs/yargs/commit/1ef44e0)) +- to allow both undefined and nulls, for benefit of TypeScript ([#945](https://github.com/yargs/yargs/issues/945)) ([792564d](https://github.com/yargs/yargs/commit/792564d)) ### BREAKING CHANGES -* version() and help() are now enabled by default, and show up in help output; the implicit help command can no longer be enabled/disabled independently from the help command itself (which can now be disabled). -* parse() now behaves as an alias for .argv, unless a parseCallback is provided. - - +- version() and help() are now enabled by default, and show up in help output; the implicit help command can no longer be enabled/disabled independently from the help command itself (which can now be disabled). +- parse() now behaves as an alias for .argv, unless a parseCallback is provided. -## [8.0.2](https://github.com/yargs/yargs/compare/v8.0.1...v8.0.2) (2017-06-12) - +## [8.0.2](https://github.com/yargs/yargs/compare/v8.0.1...v8.0.2) (2017-06-12) -## [8.0.1](https://github.com/yargs/yargs/compare/v8.0.0...v8.0.1) (2017-05-02) - +## [8.0.1](https://github.com/yargs/yargs/compare/v8.0.0...v8.0.1) (2017-05-02) -# [8.0.0](https://github.com/yargs/yargs/compare/v7.1.0...v8.0.0) (2017-05-01) +# [8.0.0](https://github.com/yargs/yargs/compare/v7.1.0...v8.0.0) (2017-05-01) ### Bug Fixes -* commands are now applied in order, from left to right ([#857](https://github.com/yargs/yargs/issues/857)) ([baba863](https://github.com/yargs/yargs/commit/baba863)) -* help now takes precedence over command recommendation ([#866](https://github.com/yargs/yargs/issues/866)) ([17e3567](https://github.com/yargs/yargs/commit/17e3567)) -* positional arguments now work if no handler is provided to inner command ([#864](https://github.com/yargs/yargs/issues/864)) ([e28ded3](https://github.com/yargs/yargs/commit/e28ded3)) - +- commands are now applied in order, from left to right ([#857](https://github.com/yargs/yargs/issues/857)) ([baba863](https://github.com/yargs/yargs/commit/baba863)) +- help now takes precedence over command recommendation ([#866](https://github.com/yargs/yargs/issues/866)) ([17e3567](https://github.com/yargs/yargs/commit/17e3567)) +- positional arguments now work if no handler is provided to inner command ([#864](https://github.com/yargs/yargs/issues/864)) ([e28ded3](https://github.com/yargs/yargs/commit/e28ded3)) ### Chores -* upgrade yargs-parser ([#867](https://github.com/yargs/yargs/issues/867)) ([8f9c6c6](https://github.com/yargs/yargs/commit/8f9c6c6)) - +- upgrade yargs-parser ([#867](https://github.com/yargs/yargs/issues/867)) ([8f9c6c6](https://github.com/yargs/yargs/commit/8f9c6c6)) ### Features -* allow extends to inherit from a module ([#865](https://github.com/yargs/yargs/issues/865)) ([89456d9](https://github.com/yargs/yargs/commit/89456d9)) -* allow strict mode to be disabled ([#840](https://github.com/yargs/yargs/issues/840)) ([6f78c05](https://github.com/yargs/yargs/commit/6f78c05)) - +- allow extends to inherit from a module ([#865](https://github.com/yargs/yargs/issues/865)) ([89456d9](https://github.com/yargs/yargs/commit/89456d9)) +- allow strict mode to be disabled ([#840](https://github.com/yargs/yargs/issues/840)) ([6f78c05](https://github.com/yargs/yargs/commit/6f78c05)) ### BREAKING CHANGES -* extends functionality now always loads the JSON provided, rather than reading from a specific key -* Node 4+ is now required; this will allow us to start updating our dependencies. -* the first argument to strict() is now used to enable/disable its functionality, rather than controlling whether or not it is global. - - +- extends functionality now always loads the JSON provided, rather than reading from a specific key +- Node 4+ is now required; this will allow us to start updating our dependencies. +- the first argument to strict() is now used to enable/disable its functionality, rather than controlling whether or not it is global. -# [7.1.0](https://github.com/yargs/yargs/compare/v7.0.2...v7.1.0) (2017-04-13) +# [7.1.0](https://github.com/yargs/yargs/compare/v7.0.2...v7.1.0) (2017-04-13) ### Bug Fixes -* fix demandOption no longer treats 'false' as truthy ([#829](https://github.com/yargs/yargs/issues/829)) ([c748dd2](https://github.com/yargs/yargs/commit/c748dd2)) -* get terminalWidth in non interactive mode no longer causes a validation exception ([#837](https://github.com/yargs/yargs/issues/837)) ([360e301](https://github.com/yargs/yargs/commit/360e301)) -* we shouldn't output help if we've printed a prior help-like message ([#847](https://github.com/yargs/yargs/issues/847)) ([17e89bd](https://github.com/yargs/yargs/commit/17e89bd)) - +- fix demandOption no longer treats 'false' as truthy ([#829](https://github.com/yargs/yargs/issues/829)) ([c748dd2](https://github.com/yargs/yargs/commit/c748dd2)) +- get terminalWidth in non interactive mode no longer causes a validation exception ([#837](https://github.com/yargs/yargs/issues/837)) ([360e301](https://github.com/yargs/yargs/commit/360e301)) +- we shouldn't output help if we've printed a prior help-like message ([#847](https://github.com/yargs/yargs/issues/847)) ([17e89bd](https://github.com/yargs/yargs/commit/17e89bd)) ### Features -* add support for numeric commands ([#825](https://github.com/yargs/yargs/issues/825)) ([fde0564](https://github.com/yargs/yargs/commit/fde0564)) - - +- add support for numeric commands ([#825](https://github.com/yargs/yargs/issues/825)) ([fde0564](https://github.com/yargs/yargs/commit/fde0564)) -## [7.0.2](https://github.com/yargs/yargs/compare/v7.0.1...v7.0.2) (2017-03-10) +## [7.0.2](https://github.com/yargs/yargs/compare/v7.0.1...v7.0.2) (2017-03-10) ### Bug Fixes -* populating placeholder arguments broke validation ([b3eb2fe](https://github.com/yargs/yargs/commit/b3eb2fe)) - - +- populating placeholder arguments broke validation ([b3eb2fe](https://github.com/yargs/yargs/commit/b3eb2fe)) -## [7.0.1](https://github.com/yargs/yargs/compare/v7.0.0...v7.0.1) (2017-03-03) +## [7.0.1](https://github.com/yargs/yargs/compare/v7.0.0...v7.0.1) (2017-03-03) ### Bug Fixes -* --help with default command should print top-level help ([#810](https://github.com/yargs/yargs/issues/810)) ([9c03fa4](https://github.com/yargs/yargs/commit/9c03fa4)) - - +- --help with default command should print top-level help ([#810](https://github.com/yargs/yargs/issues/810)) ([9c03fa4](https://github.com/yargs/yargs/commit/9c03fa4)) -# [7.0.0](https://github.com/yargs/yargs/compare/v6.6.0...v7.0.0) (2017-02-26) +# [7.0.0](https://github.com/yargs/yargs/compare/v6.6.0...v7.0.0) (2017-02-26) ### Bug Fixes -* address min/max validation message regression ([#750](https://github.com/yargs/yargs/issues/750)) ([2e5ce0f](https://github.com/yargs/yargs/commit/2e5ce0f)) -* address positional argument strict() bug introduced in [#766](https://github.com/yargs/yargs/issues/766) ([#784](https://github.com/yargs/yargs/issues/784)) ([a8528e6](https://github.com/yargs/yargs/commit/a8528e6)) -* console.warn() rather than throwing errors when api signatures are incorrect ([#804](https://github.com/yargs/yargs/issues/804)) ([a607061](https://github.com/yargs/yargs/commit/a607061)) -* context should override parsed argv ([#786](https://github.com/yargs/yargs/issues/786)) ([0997288](https://github.com/yargs/yargs/commit/0997288)) -* context variables are now recognized in strict() mode ([#796](https://github.com/yargs/yargs/issues/796)) ([48575cd](https://github.com/yargs/yargs/commit/48575cd)) -* errors were not bubbling appropriately from sub-commands to top-level ([#802](https://github.com/yargs/yargs/issues/802)) ([8a992f5](https://github.com/yargs/yargs/commit/8a992f5)) -* positional arguments of sub-commands threw strict() exception ([#805](https://github.com/yargs/yargs/issues/805)) ([f3f074b](https://github.com/yargs/yargs/commit/f3f074b)) -* pull in yargs-parser with modified env precedence ([#787](https://github.com/yargs/yargs/issues/787)) ([e0fbbe5](https://github.com/yargs/yargs/commit/e0fbbe5)) -* running parse() multiple times on the same yargs instance caused exception if help() enabled ([#790](https://github.com/yargs/yargs/issues/790)) ([07e39b7](https://github.com/yargs/yargs/commit/07e39b7)) -* use path.resolve() to support node 0.10 ([#797](https://github.com/yargs/yargs/issues/797)) ([49a93fc](https://github.com/yargs/yargs/commit/49a93fc)) - +- address min/max validation message regression ([#750](https://github.com/yargs/yargs/issues/750)) ([2e5ce0f](https://github.com/yargs/yargs/commit/2e5ce0f)) +- address positional argument strict() bug introduced in [#766](https://github.com/yargs/yargs/issues/766) ([#784](https://github.com/yargs/yargs/issues/784)) ([a8528e6](https://github.com/yargs/yargs/commit/a8528e6)) +- console.warn() rather than throwing errors when api signatures are incorrect ([#804](https://github.com/yargs/yargs/issues/804)) ([a607061](https://github.com/yargs/yargs/commit/a607061)) +- context should override parsed argv ([#786](https://github.com/yargs/yargs/issues/786)) ([0997288](https://github.com/yargs/yargs/commit/0997288)) +- context variables are now recognized in strict() mode ([#796](https://github.com/yargs/yargs/issues/796)) ([48575cd](https://github.com/yargs/yargs/commit/48575cd)) +- errors were not bubbling appropriately from sub-commands to top-level ([#802](https://github.com/yargs/yargs/issues/802)) ([8a992f5](https://github.com/yargs/yargs/commit/8a992f5)) +- positional arguments of sub-commands threw strict() exception ([#805](https://github.com/yargs/yargs/issues/805)) ([f3f074b](https://github.com/yargs/yargs/commit/f3f074b)) +- pull in yargs-parser with modified env precedence ([#787](https://github.com/yargs/yargs/issues/787)) ([e0fbbe5](https://github.com/yargs/yargs/commit/e0fbbe5)) +- running parse() multiple times on the same yargs instance caused exception if help() enabled ([#790](https://github.com/yargs/yargs/issues/790)) ([07e39b7](https://github.com/yargs/yargs/commit/07e39b7)) +- use path.resolve() to support node 0.10 ([#797](https://github.com/yargs/yargs/issues/797)) ([49a93fc](https://github.com/yargs/yargs/commit/49a93fc)) ### Features -* add conflicts and implies shorthands. ([#753](https://github.com/yargs/yargs/issues/753)) ([bd1472b](https://github.com/yargs/yargs/commit/bd1472b)) -* add traditional Chinese translation ([#780](https://github.com/yargs/yargs/issues/780)) ([6ab6a95](https://github.com/yargs/yargs/commit/6ab6a95)) -* allow provided config object to extend other configs ([#779](https://github.com/yargs/yargs/issues/779)) ([3280dd0](https://github.com/yargs/yargs/commit/3280dd0)) -* function argument validation ([#773](https://github.com/yargs/yargs/issues/773)) ([22ed9bb](https://github.com/yargs/yargs/commit/22ed9bb)) -* if only one column is provided for examples, allow it to take up the entire line ([#749](https://github.com/yargs/yargs/issues/749)) ([7931652](https://github.com/yargs/yargs/commit/7931652)) -* introduce custom yargs error object ([#765](https://github.com/yargs/yargs/issues/765)) ([8308efa](https://github.com/yargs/yargs/commit/8308efa)) -* introduces support for default commands, using the '*' identifier ([#785](https://github.com/yargs/yargs/issues/785)) ([d78a0f5](https://github.com/yargs/yargs/commit/d78a0f5)) -* rethink how options are inherited by commands ([#766](https://github.com/yargs/yargs/issues/766)) ([ab1fa4b](https://github.com/yargs/yargs/commit/ab1fa4b)) - +- add conflicts and implies shorthands. ([#753](https://github.com/yargs/yargs/issues/753)) ([bd1472b](https://github.com/yargs/yargs/commit/bd1472b)) +- add traditional Chinese translation ([#780](https://github.com/yargs/yargs/issues/780)) ([6ab6a95](https://github.com/yargs/yargs/commit/6ab6a95)) +- allow provided config object to extend other configs ([#779](https://github.com/yargs/yargs/issues/779)) ([3280dd0](https://github.com/yargs/yargs/commit/3280dd0)) +- function argument validation ([#773](https://github.com/yargs/yargs/issues/773)) ([22ed9bb](https://github.com/yargs/yargs/commit/22ed9bb)) +- if only one column is provided for examples, allow it to take up the entire line ([#749](https://github.com/yargs/yargs/issues/749)) ([7931652](https://github.com/yargs/yargs/commit/7931652)) +- introduce custom yargs error object ([#765](https://github.com/yargs/yargs/issues/765)) ([8308efa](https://github.com/yargs/yargs/commit/8308efa)) +- introduces support for default commands, using the '\*' identifier ([#785](https://github.com/yargs/yargs/issues/785)) ([d78a0f5](https://github.com/yargs/yargs/commit/d78a0f5)) +- rethink how options are inherited by commands ([#766](https://github.com/yargs/yargs/issues/766)) ([ab1fa4b](https://github.com/yargs/yargs/commit/ab1fa4b)) ### BREAKING CHANGES -* `extends` key in config file is now used for extending other config files -* environment variables now take precedence over config files. -* context now takes precedence over argv and defaults -* the arguments passed to functions are now validated, there's a good chance this will throw exceptions for a few folks who are using the API in an unexpected way. -* by default options, and many of yargs' parsing helpers will now default to being applied globally; such that they are no-longer reset before being passed into commands. -* yargs will no longer aggressively suppress errors, allowing errors that are not generated internally to bubble. - - +- `extends` key in config file is now used for extending other config files +- environment variables now take precedence over config files. +- context now takes precedence over argv and defaults +- the arguments passed to functions are now validated, there's a good chance this will throw exceptions for a few folks who are using the API in an unexpected way. +- by default options, and many of yargs' parsing helpers will now default to being applied globally; such that they are no-longer reset before being passed into commands. +- yargs will no longer aggressively suppress errors, allowing errors that are not generated internally to bubble. -# [6.6.0](https://github.com/yargs/yargs/compare/v6.5.0...v6.6.0) (2016-12-29) +# [6.6.0](https://github.com/yargs/yargs/compare/v6.5.0...v6.6.0) (2016-12-29) ### Bug Fixes -* [object Object] was accidentally being populated on options object ([#736](https://github.com/yargs/yargs/issues/736)) ([f755e27](https://github.com/yargs/yargs/commit/f755e27)) -* do not use cwd when resolving package.json for yargs parsing config ([#726](https://github.com/yargs/yargs/issues/726)) ([9bdaab7](https://github.com/yargs/yargs/commit/9bdaab7)) - +- [object Object] was accidentally being populated on options object ([#736](https://github.com/yargs/yargs/issues/736)) ([f755e27](https://github.com/yargs/yargs/commit/f755e27)) +- do not use cwd when resolving package.json for yargs parsing config ([#726](https://github.com/yargs/yargs/issues/726)) ([9bdaab7](https://github.com/yargs/yargs/commit/9bdaab7)) ### Features -* implement conflicts() for defining mutually exclusive arguments; thanks [@madcampos](https://github.com/madcampos)! ([#741](https://github.com/yargs/yargs/issues/741)) ([5883779](https://github.com/yargs/yargs/commit/5883779)) -* split demand() into demandCommand()/demandOption() ([#740](https://github.com/yargs/yargs/issues/740)) ([66573c8](https://github.com/yargs/yargs/commit/66573c8)) -* support for positional argument aliases ([#727](https://github.com/yargs/yargs/issues/727)) ([27e1a57](https://github.com/yargs/yargs/commit/27e1a57)) - - +- implement conflicts() for defining mutually exclusive arguments; thanks [@madcampos](https://github.com/madcampos)! ([#741](https://github.com/yargs/yargs/issues/741)) ([5883779](https://github.com/yargs/yargs/commit/5883779)) +- split demand() into demandCommand()/demandOption() ([#740](https://github.com/yargs/yargs/issues/740)) ([66573c8](https://github.com/yargs/yargs/commit/66573c8)) +- support for positional argument aliases ([#727](https://github.com/yargs/yargs/issues/727)) ([27e1a57](https://github.com/yargs/yargs/commit/27e1a57)) -# [6.5.0](https://github.com/yargs/yargs/compare/v6.4.0...v6.5.0) (2016-12-01) +# [6.5.0](https://github.com/yargs/yargs/compare/v6.4.0...v6.5.0) (2016-12-01) ### Bug Fixes -* still freeze/unfreeze if parse() is called in isolation ([#717](https://github.com/yargs/yargs/issues/717)) ([30a9492](https://github.com/yargs/yargs/commit/30a9492)) - +- still freeze/unfreeze if parse() is called in isolation ([#717](https://github.com/yargs/yargs/issues/717)) ([30a9492](https://github.com/yargs/yargs/commit/30a9492)) ### Features -* pull in yargs-parser introducing additional settings ([#688](https://github.com/yargs/yargs/issues/688)), and fixing [#716](https://github.com/yargs/yargs/issues/716) ([#722](https://github.com/yargs/yargs/issues/722)) ([702995a](https://github.com/yargs/yargs/commit/702995a)) - - +- pull in yargs-parser introducing additional settings ([#688](https://github.com/yargs/yargs/issues/688)), and fixing [#716](https://github.com/yargs/yargs/issues/716) ([#722](https://github.com/yargs/yargs/issues/722)) ([702995a](https://github.com/yargs/yargs/commit/702995a)) -# [6.4.0](https://github.com/yargs/yargs/compare/v6.3.0...v6.4.0) (2016-11-13) +# [6.4.0](https://github.com/yargs/yargs/compare/v6.3.0...v6.4.0) (2016-11-13) ### Bug Fixes -* **locales:** correct some Russian translations ([#691](https://github.com/yargs/yargs/issues/691)) ([a980671](https://github.com/yargs/yargs/commit/a980671)) - +- **locales:** correct some Russian translations ([#691](https://github.com/yargs/yargs/issues/691)) ([a980671](https://github.com/yargs/yargs/commit/a980671)) ### Features -* **locales:** Added Belarusian translation ([#690](https://github.com/yargs/yargs/issues/690)) ([68dac1f](https://github.com/yargs/yargs/commit/68dac1f)) -* **locales:** Create nl.json ([#687](https://github.com/yargs/yargs/issues/687)) ([46ce1bb](https://github.com/yargs/yargs/commit/46ce1bb)) -* update to yargs-parser that addresses [#598](https://github.com/yargs/yargs/issues/598), [#617](https://github.com/yargs/yargs/issues/617) ([#700](https://github.com/yargs/yargs/issues/700)) ([54cb31d](https://github.com/yargs/yargs/commit/54cb31d)) -* yargs is now passed as the third-argument to fail handler ([#613](https://github.com/yargs/yargs/issues/613)) ([21b74f9](https://github.com/yargs/yargs/commit/21b74f9)) - +- **locales:** Added Belarusian translation ([#690](https://github.com/yargs/yargs/issues/690)) ([68dac1f](https://github.com/yargs/yargs/commit/68dac1f)) +- **locales:** Create nl.json ([#687](https://github.com/yargs/yargs/issues/687)) ([46ce1bb](https://github.com/yargs/yargs/commit/46ce1bb)) +- update to yargs-parser that addresses [#598](https://github.com/yargs/yargs/issues/598), [#617](https://github.com/yargs/yargs/issues/617) ([#700](https://github.com/yargs/yargs/issues/700)) ([54cb31d](https://github.com/yargs/yargs/commit/54cb31d)) +- yargs is now passed as the third-argument to fail handler ([#613](https://github.com/yargs/yargs/issues/613)) ([21b74f9](https://github.com/yargs/yargs/commit/21b74f9)) ### Performance Improvements -* normalizing package data is an expensive operation ([#705](https://github.com/yargs/yargs/issues/705)) ([49cf533](https://github.com/yargs/yargs/commit/49cf533)) - - +- normalizing package data is an expensive operation ([#705](https://github.com/yargs/yargs/issues/705)) ([49cf533](https://github.com/yargs/yargs/commit/49cf533)) -# [6.3.0](https://github.com/yargs/yargs/compare/v6.2.0...v6.3.0) (2016-10-19) +# [6.3.0](https://github.com/yargs/yargs/compare/v6.2.0...v6.3.0) (2016-10-19) ### Bug Fixes -* **command:** subcommands via commandDir() now supported for parse(msg, cb) ([#678](https://github.com/yargs/yargs/issues/678)) ([6b85cc6](https://github.com/yargs/yargs/commit/6b85cc6)) - +- **command:** subcommands via commandDir() now supported for parse(msg, cb) ([#678](https://github.com/yargs/yargs/issues/678)) ([6b85cc6](https://github.com/yargs/yargs/commit/6b85cc6)) ### Features -* **locales:** Add Thai locale file ([#679](https://github.com/yargs/yargs/issues/679)) ([c05e36b](https://github.com/yargs/yargs/commit/c05e36b)) - - +- **locales:** Add Thai locale file ([#679](https://github.com/yargs/yargs/issues/679)) ([c05e36b](https://github.com/yargs/yargs/commit/c05e36b)) -# [6.2.0](https://github.com/yargs/yargs/compare/v6.1.1...v6.2.0) (2016-10-16) +# [6.2.0](https://github.com/yargs/yargs/compare/v6.1.1...v6.2.0) (2016-10-16) ### Bug Fixes -* stop applying parser to context object ([#675](https://github.com/yargs/yargs/issues/675)) ([3fe9b8f](https://github.com/yargs/yargs/commit/3fe9b8f)) - +- stop applying parser to context object ([#675](https://github.com/yargs/yargs/issues/675)) ([3fe9b8f](https://github.com/yargs/yargs/commit/3fe9b8f)) ### Features -* add new pt_BR translations ([#674](https://github.com/yargs/yargs/issues/674)) ([5615a82](https://github.com/yargs/yargs/commit/5615a82)) -* Italian translations for 'did you mean' and 'aliases' ([#673](https://github.com/yargs/yargs/issues/673)) ([81984e6](https://github.com/yargs/yargs/commit/81984e6)) - - +- add new pt_BR translations ([#674](https://github.com/yargs/yargs/issues/674)) ([5615a82](https://github.com/yargs/yargs/commit/5615a82)) +- Italian translations for 'did you mean' and 'aliases' ([#673](https://github.com/yargs/yargs/issues/673)) ([81984e6](https://github.com/yargs/yargs/commit/81984e6)) -## [6.1.1](https://github.com/yargs/yargs/compare/v6.1.0...v6.1.1) (2016-10-15) +## [6.1.1](https://github.com/yargs/yargs/compare/v6.1.0...v6.1.1) (2016-10-15) ### Bug Fixes -* freeze was not resetting configObjects to initial state; addressed performance issue raised by [@nexdrew](https://github.com/nexdrew). ([#670](https://github.com/yargs/yargs/issues/670)) ([ae4bcd4](https://github.com/yargs/yargs/commit/ae4bcd4)) - - +- freeze was not resetting configObjects to initial state; addressed performance issue raised by [@nexdrew](https://github.com/nexdrew). ([#670](https://github.com/yargs/yargs/issues/670)) ([ae4bcd4](https://github.com/yargs/yargs/commit/ae4bcd4)) -# [6.1.0](https://github.com/yargs/yargs/compare/v6.0.0...v6.1.0) (2016-10-15) +# [6.1.0](https://github.com/yargs/yargs/compare/v6.0.0...v6.1.0) (2016-10-15) ### Bug Fixes -* **locales:** change some translations ([#667](https://github.com/yargs/yargs/issues/667)) ([aa966c5](https://github.com/yargs/yargs/commit/aa966c5)) -* **locales:** conform hi locale to y18n.__n expectations ([#666](https://github.com/yargs/yargs/issues/666)) ([22adb18](https://github.com/yargs/yargs/commit/22adb18)) - +- **locales:** change some translations ([#667](https://github.com/yargs/yargs/issues/667)) ([aa966c5](https://github.com/yargs/yargs/commit/aa966c5)) +- **locales:** conform hi locale to y18n.\_\_n expectations ([#666](https://github.com/yargs/yargs/issues/666)) ([22adb18](https://github.com/yargs/yargs/commit/22adb18)) ### Features -* initial support for command aliases ([#647](https://github.com/yargs/yargs/issues/647)) ([127a040](https://github.com/yargs/yargs/commit/127a040)) -* **command:** add camelcase commands to argv ([#658](https://github.com/yargs/yargs/issues/658)) ([b1cabae](https://github.com/yargs/yargs/commit/b1cabae)) -* **locales:** add Hindi translations ([9290912](https://github.com/yargs/yargs/commit/9290912)) -* **locales:** add Hungarian translations ([be92327](https://github.com/yargs/yargs/commit/be92327)) -* **locales:** Japanese translations for 'did you mean' and 'aliases' ([#651](https://github.com/yargs/yargs/issues/651)) ([5eb78fc](https://github.com/yargs/yargs/commit/5eb78fc)) -* **locales:** Polish translations for 'did you mean' and 'aliases' ([#650](https://github.com/yargs/yargs/issues/650)) ([c951c0e](https://github.com/yargs/yargs/commit/c951c0e)) -* reworking yargs API to make it easier to run in headless environments, e.g., Slack ([#646](https://github.com/yargs/yargs/issues/646)) ([f284c29](https://github.com/yargs/yargs/commit/f284c29)) -* Turkish translations for 'did you mean' and 'aliases' ([#660](https://github.com/yargs/yargs/issues/660)) ([072fd45](https://github.com/yargs/yargs/commit/072fd45)) - - +- initial support for command aliases ([#647](https://github.com/yargs/yargs/issues/647)) ([127a040](https://github.com/yargs/yargs/commit/127a040)) +- **command:** add camelcase commands to argv ([#658](https://github.com/yargs/yargs/issues/658)) ([b1cabae](https://github.com/yargs/yargs/commit/b1cabae)) +- **locales:** add Hindi translations ([9290912](https://github.com/yargs/yargs/commit/9290912)) +- **locales:** add Hungarian translations ([be92327](https://github.com/yargs/yargs/commit/be92327)) +- **locales:** Japanese translations for 'did you mean' and 'aliases' ([#651](https://github.com/yargs/yargs/issues/651)) ([5eb78fc](https://github.com/yargs/yargs/commit/5eb78fc)) +- **locales:** Polish translations for 'did you mean' and 'aliases' ([#650](https://github.com/yargs/yargs/issues/650)) ([c951c0e](https://github.com/yargs/yargs/commit/c951c0e)) +- reworking yargs API to make it easier to run in headless environments, e.g., Slack ([#646](https://github.com/yargs/yargs/issues/646)) ([f284c29](https://github.com/yargs/yargs/commit/f284c29)) +- Turkish translations for 'did you mean' and 'aliases' ([#660](https://github.com/yargs/yargs/issues/660)) ([072fd45](https://github.com/yargs/yargs/commit/072fd45)) -# [6.0.0](https://github.com/yargs/yargs/compare/v5.0.0...v6.0.0) (2016-09-30) +# [6.0.0](https://github.com/yargs/yargs/compare/v5.0.0...v6.0.0) (2016-09-30) ### Bug Fixes -* changed parsing of the command string to ignore extra spaces ([#600](https://github.com/yargs/yargs/issues/600)) ([e8e5a72](https://github.com/yargs/yargs/commit/e8e5a72)) -* drop lodash.assign ([#641](https://github.com/yargs/yargs/issues/641)) ([ad3146f](https://github.com/yargs/yargs/commit/ad3146f)) -* for args that have skipValidation set to `true`, check if the parsed arg is `true` ([#619](https://github.com/yargs/yargs/issues/619)) ([658a34c](https://github.com/yargs/yargs/commit/658a34c)) -* upgrade standard, and fix appveyor config so that it works with newest standard ([#607](https://github.com/yargs/yargs/issues/607)) ([c301f42](https://github.com/yargs/yargs/commit/c301f42)) - +- changed parsing of the command string to ignore extra spaces ([#600](https://github.com/yargs/yargs/issues/600)) ([e8e5a72](https://github.com/yargs/yargs/commit/e8e5a72)) +- drop lodash.assign ([#641](https://github.com/yargs/yargs/issues/641)) ([ad3146f](https://github.com/yargs/yargs/commit/ad3146f)) +- for args that have skipValidation set to `true`, check if the parsed arg is `true` ([#619](https://github.com/yargs/yargs/issues/619)) ([658a34c](https://github.com/yargs/yargs/commit/658a34c)) +- upgrade standard, and fix appveyor config so that it works with newest standard ([#607](https://github.com/yargs/yargs/issues/607)) ([c301f42](https://github.com/yargs/yargs/commit/c301f42)) ### Chores -* upgrade yargs-parser ([#633](https://github.com/yargs/yargs/issues/633)) ([cc1224e](https://github.com/yargs/yargs/commit/cc1224e)) - +- upgrade yargs-parser ([#633](https://github.com/yargs/yargs/issues/633)) ([cc1224e](https://github.com/yargs/yargs/commit/cc1224e)) ### Features -* make opts object optional for .option() ([#624](https://github.com/yargs/yargs/issues/624)) ([4f29de6](https://github.com/yargs/yargs/commit/4f29de6)) - +- make opts object optional for .option() ([#624](https://github.com/yargs/yargs/issues/624)) ([4f29de6](https://github.com/yargs/yargs/commit/4f29de6)) ### Performance Improvements -* defer windowWidth() to improve perf for non-help usage ([#610](https://github.com/yargs/yargs/issues/610)) ([cbc3636](https://github.com/yargs/yargs/commit/cbc3636)) - +- defer windowWidth() to improve perf for non-help usage ([#610](https://github.com/yargs/yargs/issues/610)) ([cbc3636](https://github.com/yargs/yargs/commit/cbc3636)) ### BREAKING CHANGES -* coerce is now applied as a final step after other parsing is complete - - +- coerce is now applied as a final step after other parsing is complete -# [5.0.0](https://github.com/yargs/yargs/compare/v4.8.1...v5.0.0) (2016-08-14) +# [5.0.0](https://github.com/yargs/yargs/compare/v4.8.1...v5.0.0) (2016-08-14) ### Bug Fixes -* **default:** Remove undocumented alias of default() ([#469](https://github.com/yargs/yargs/issues/469)) ([b8591b2](https://github.com/yargs/yargs/commit/b8591b2)) -* remove deprecated zh.json ([#578](https://github.com/yargs/yargs/issues/578)) ([317c62c](https://github.com/yargs/yargs/commit/317c62c)) - +- **default:** Remove undocumented alias of default() ([#469](https://github.com/yargs/yargs/issues/469)) ([b8591b2](https://github.com/yargs/yargs/commit/b8591b2)) +- remove deprecated zh.json ([#578](https://github.com/yargs/yargs/issues/578)) ([317c62c](https://github.com/yargs/yargs/commit/317c62c)) ### Features -* .help() API can now enable implicit help command ([#574](https://github.com/yargs/yargs/issues/574)) ([7645019](https://github.com/yargs/yargs/commit/7645019)) -* **command:** builder function no longer needs to return the yargs instance ([#549](https://github.com/yargs/yargs/issues/549)) ([eaa2873](https://github.com/yargs/yargs/commit/eaa2873)) -* add coerce api ([#586](https://github.com/yargs/yargs/issues/586)) ([1d53ccb](https://github.com/yargs/yargs/commit/1d53ccb)) -* adds recommendCommands() for command suggestions ([#580](https://github.com/yargs/yargs/issues/580)) ([59474dc](https://github.com/yargs/yargs/commit/59474dc)) -* apply .env() globally ([#553](https://github.com/yargs/yargs/issues/553)) ([be65728](https://github.com/yargs/yargs/commit/be65728)) -* apply default builder to command() and apply fail() handlers globally ([#583](https://github.com/yargs/yargs/issues/583)) ([0aaa68b](https://github.com/yargs/yargs/commit/0aaa68b)) -* update yargs-parser to version 3.1.0 ([#581](https://github.com/yargs/yargs/issues/581)) ([882a127](https://github.com/yargs/yargs/commit/882a127)) - +- .help() API can now enable implicit help command ([#574](https://github.com/yargs/yargs/issues/574)) ([7645019](https://github.com/yargs/yargs/commit/7645019)) +- **command:** builder function no longer needs to return the yargs instance ([#549](https://github.com/yargs/yargs/issues/549)) ([eaa2873](https://github.com/yargs/yargs/commit/eaa2873)) +- add coerce api ([#586](https://github.com/yargs/yargs/issues/586)) ([1d53ccb](https://github.com/yargs/yargs/commit/1d53ccb)) +- adds recommendCommands() for command suggestions ([#580](https://github.com/yargs/yargs/issues/580)) ([59474dc](https://github.com/yargs/yargs/commit/59474dc)) +- apply .env() globally ([#553](https://github.com/yargs/yargs/issues/553)) ([be65728](https://github.com/yargs/yargs/commit/be65728)) +- apply default builder to command() and apply fail() handlers globally ([#583](https://github.com/yargs/yargs/issues/583)) ([0aaa68b](https://github.com/yargs/yargs/commit/0aaa68b)) +- update yargs-parser to version 3.1.0 ([#581](https://github.com/yargs/yargs/issues/581)) ([882a127](https://github.com/yargs/yargs/commit/882a127)) ### Performance Improvements -* defer requiring most external libs until needed ([#584](https://github.com/yargs/yargs/issues/584)) ([f9b0ed4](https://github.com/yargs/yargs/commit/f9b0ed4)) - +- defer requiring most external libs until needed ([#584](https://github.com/yargs/yargs/issues/584)) ([f9b0ed4](https://github.com/yargs/yargs/commit/f9b0ed4)) ### BREAKING CHANGES -* fail is now applied globally. -* we now default to an empty builder function when command is executed with no builder. -* yargs-parser now better handles negative integer values, at the cost of handling numeric option names, e.g., -1 hello -* default: removed undocumented `defaults` alias for `default`. -* introduces a default `help` command which outputs help, as an alternative to a help flag. -* interpret demand() numbers as relative to executing command ([#582](https://github.com/yargs/yargs/issues/582)) ([927810c](https://github.com/yargs/yargs/commit/927810c)) - - +- fail is now applied globally. +- we now default to an empty builder function when command is executed with no builder. +- yargs-parser now better handles negative integer values, at the cost of handling numeric option names, e.g., -1 hello +- default: removed undocumented `defaults` alias for `default`. +- introduces a default `help` command which outputs help, as an alternative to a help flag. +- interpret demand() numbers as relative to executing command ([#582](https://github.com/yargs/yargs/issues/582)) ([927810c](https://github.com/yargs/yargs/commit/927810c)) -## [4.8.1](https://github.com/yargs/yargs/compare/v4.8.0...v4.8.1) (2016-07-16) +## [4.8.1](https://github.com/yargs/yargs/compare/v4.8.0...v4.8.1) (2016-07-16) ### Bug Fixes -* **commandDir:** make dir relative to caller instead of require.main.filename ([#548](https://github.com/yargs/yargs/issues/548)) ([3c2e479](https://github.com/yargs/yargs/commit/3c2e479)) -* add config lookup for .implies() ([#556](https://github.com/yargs/yargs/issues/556)) ([8d7585c](https://github.com/yargs/yargs/commit/8d7585c)) -* cache pkg lookups by path to avoid returning the wrong one ([#552](https://github.com/yargs/yargs/issues/552)) ([fea7e0b](https://github.com/yargs/yargs/commit/fea7e0b)) -* positional arguments were not being handled appropriately by parse() ([#559](https://github.com/yargs/yargs/issues/559)) ([063a866](https://github.com/yargs/yargs/commit/063a866)) -* pull in [@nexdrew](https://github.com/nexdrew)'s fixes to yargs-parser ([#560](https://github.com/yargs/yargs/issues/560)) ([c77c080](https://github.com/yargs/yargs/commit/c77c080)), closes [#560](https://github.com/yargs/yargs/issues/560) - - +- **commandDir:** make dir relative to caller instead of require.main.filename ([#548](https://github.com/yargs/yargs/issues/548)) ([3c2e479](https://github.com/yargs/yargs/commit/3c2e479)) +- add config lookup for .implies() ([#556](https://github.com/yargs/yargs/issues/556)) ([8d7585c](https://github.com/yargs/yargs/commit/8d7585c)) +- cache pkg lookups by path to avoid returning the wrong one ([#552](https://github.com/yargs/yargs/issues/552)) ([fea7e0b](https://github.com/yargs/yargs/commit/fea7e0b)) +- positional arguments were not being handled appropriately by parse() ([#559](https://github.com/yargs/yargs/issues/559)) ([063a866](https://github.com/yargs/yargs/commit/063a866)) +- pull in [@nexdrew](https://github.com/nexdrew)'s fixes to yargs-parser ([#560](https://github.com/yargs/yargs/issues/560)) ([c77c080](https://github.com/yargs/yargs/commit/c77c080)), closes [#560](https://github.com/yargs/yargs/issues/560) -# [4.8.0](https://github.com/yargs/yargs/compare/v4.7.1...v4.8.0) (2016-07-09) +# [4.8.0](https://github.com/yargs/yargs/compare/v4.7.1...v4.8.0) (2016-07-09) ### Bug Fixes -* drop unused camelcase dependency fixes [#516](https://github.com/yargs/yargs/issues/516) ([#525](https://github.com/yargs/yargs/issues/525)) ([365fb9a](https://github.com/yargs/yargs/commit/365fb9a)), closes [#516](https://github.com/yargs/yargs/issues/516) [#525](https://github.com/yargs/yargs/issues/525) -* fake a tty in tests, so that we can use the new set-blocking ([#512](https://github.com/yargs/yargs/issues/512)) ([a54c742](https://github.com/yargs/yargs/commit/a54c742)) -* ignore invalid package.json during read-pkg-up ([#546](https://github.com/yargs/yargs/issues/546)) ([e058c87](https://github.com/yargs/yargs/commit/e058c87)) -* keep both zh and zh_CN until yargs[@5](https://github.com/5).x ([0f8faa7](https://github.com/yargs/yargs/commit/0f8faa7)) -* lazy-load package.json and cache. get rid of pkg-conf dependency. ([#544](https://github.com/yargs/yargs/issues/544)) ([2609b2e](https://github.com/yargs/yargs/commit/2609b2e)) -* we now respect the order of _ when applying commands ([#537](https://github.com/yargs/yargs/issues/537)) ([ed86b78](https://github.com/yargs/yargs/commit/ed86b78)) - +- drop unused camelcase dependency fixes [#516](https://github.com/yargs/yargs/issues/516) ([#525](https://github.com/yargs/yargs/issues/525)) ([365fb9a](https://github.com/yargs/yargs/commit/365fb9a)), closes [#516](https://github.com/yargs/yargs/issues/516) [#525](https://github.com/yargs/yargs/issues/525) +- fake a tty in tests, so that we can use the new set-blocking ([#512](https://github.com/yargs/yargs/issues/512)) ([a54c742](https://github.com/yargs/yargs/commit/a54c742)) +- ignore invalid package.json during read-pkg-up ([#546](https://github.com/yargs/yargs/issues/546)) ([e058c87](https://github.com/yargs/yargs/commit/e058c87)) +- keep both zh and zh_CN until yargs[@5](https://github.com/5).x ([0f8faa7](https://github.com/yargs/yargs/commit/0f8faa7)) +- lazy-load package.json and cache. get rid of pkg-conf dependency. ([#544](https://github.com/yargs/yargs/issues/544)) ([2609b2e](https://github.com/yargs/yargs/commit/2609b2e)) +- we now respect the order of \_ when applying commands ([#537](https://github.com/yargs/yargs/issues/537)) ([ed86b78](https://github.com/yargs/yargs/commit/ed86b78)) ### Features -* add .commandDir(dir) to API to apply all command modules from a relative directory ([#494](https://github.com/yargs/yargs/issues/494)) ([b299dff](https://github.com/yargs/yargs/commit/b299dff)) -* **command:** derive missing command string from module filename ([#527](https://github.com/yargs/yargs/issues/527)) ([20d4b8a](https://github.com/yargs/yargs/commit/20d4b8a)) -* builder is now optional for a command module ([#545](https://github.com/yargs/yargs/issues/545)) ([8d6ad6e](https://github.com/yargs/yargs/commit/8d6ad6e)) - - +- add .commandDir(dir) to API to apply all command modules from a relative directory ([#494](https://github.com/yargs/yargs/issues/494)) ([b299dff](https://github.com/yargs/yargs/commit/b299dff)) +- **command:** derive missing command string from module filename ([#527](https://github.com/yargs/yargs/issues/527)) ([20d4b8a](https://github.com/yargs/yargs/commit/20d4b8a)) +- builder is now optional for a command module ([#545](https://github.com/yargs/yargs/issues/545)) ([8d6ad6e](https://github.com/yargs/yargs/commit/8d6ad6e)) -## [4.7.1](https://github.com/yargs/yargs/compare/v4.7.0...v4.7.1) (2016-05-15) +## [4.7.1](https://github.com/yargs/yargs/compare/v4.7.0...v4.7.1) (2016-05-15) ### Bug Fixes -* switch to using `const` rather than `var` ([#499](https://github.com/yargs/yargs/pull/499)) -* make stdout flush on newer versions of Node.js ([#501](https://github.com/yargs/yargs/issues/501)) ([9f8c6f4](https://github.com/yargs/yargs/commit/9f8c6f4)) - - +- switch to using `const` rather than `var` ([#499](https://github.com/yargs/yargs/pull/499)) +- make stdout flush on newer versions of Node.js ([#501](https://github.com/yargs/yargs/issues/501)) ([9f8c6f4](https://github.com/yargs/yargs/commit/9f8c6f4)) -# [4.7.0](https://github.com/yargs/yargs/compare/v4.6.0...v4.7.0) (2016-05-02) +# [4.7.0](https://github.com/yargs/yargs/compare/v4.6.0...v4.7.0) (2016-05-02) ### Bug Fixes -* **pkgConf:** fix aliases issues in .pkgConf() ([#478](https://github.com/yargs/yargs/issues/478))([b900502](https://github.com/yargs/yargs/commit/b900502)) - +- **pkgConf:** fix aliases issues in .pkgConf() ([#478](https://github.com/yargs/yargs/issues/478))([b900502](https://github.com/yargs/yargs/commit/b900502)) ### Features -* **completion:** allow to get completions for any string, not just process.argv ([#470](https://github.com/yargs/yargs/issues/470))([74fcfbc](https://github.com/yargs/yargs/commit/74fcfbc)) -* **configuration:** Allow to directly pass a configuration object to .config() ([#480](https://github.com/yargs/yargs/issues/480))([e0a7e05](https://github.com/yargs/yargs/commit/e0a7e05)) -* **validation:** Add .skipValidation() method ([#471](https://github.com/yargs/yargs/issues/471))([d72badb](https://github.com/yargs/yargs/commit/d72badb)) - - +- **completion:** allow to get completions for any string, not just process.argv ([#470](https://github.com/yargs/yargs/issues/470))([74fcfbc](https://github.com/yargs/yargs/commit/74fcfbc)) +- **configuration:** Allow to directly pass a configuration object to .config() ([#480](https://github.com/yargs/yargs/issues/480))([e0a7e05](https://github.com/yargs/yargs/commit/e0a7e05)) +- **validation:** Add .skipValidation() method ([#471](https://github.com/yargs/yargs/issues/471))([d72badb](https://github.com/yargs/yargs/commit/d72badb)) -# [4.6.0](https://github.com/yargs/yargs/compare/v4.5.0...v4.6.0) (2016-04-11) +# [4.6.0](https://github.com/yargs/yargs/compare/v4.5.0...v4.6.0) (2016-04-11) ### Bug Fixes -* **my brand!:** I agree with [@osher](https://github.com/osher) lightweight isn't a huge selling point of ours any longer, see [#468](https://github.com/yargs/yargs/issues/468) ([c46d7e1](https://github.com/yargs/yargs/commit/c46d7e1)) +- **my brand!:** I agree with [@osher](https://github.com/osher) lightweight isn't a huge selling point of ours any longer, see [#468](https://github.com/yargs/yargs/issues/468) ([c46d7e1](https://github.com/yargs/yargs/commit/c46d7e1)) ### Features -* switch to standard-version for release management ([f70f801](https://github.com/yargs/yargs/commit/f70f801)) -* upgrade to version of yargs-parser that introduces some slick new features, great work [@elas7](https://github.com/elas7). update cliui, replace win-spawn, replace badge. ([#475](https://github.com/yargs/yargs/issues/475)) ([f915dd4](https://github.com/yargs/yargs/commit/f915dd4)) - - +- switch to standard-version for release management ([f70f801](https://github.com/yargs/yargs/commit/f70f801)) +- upgrade to version of yargs-parser that introduces some slick new features, great work [@elas7](https://github.com/elas7). update cliui, replace win-spawn, replace badge. ([#475](https://github.com/yargs/yargs/issues/475)) ([f915dd4](https://github.com/yargs/yargs/commit/f915dd4)) -# [4.5.0](https://github.com/yargs/yargs/compare/v4.4.0...v4.5.0) (2016-04-05) +# [4.5.0](https://github.com/yargs/yargs/compare/v4.4.0...v4.5.0) (2016-04-05) ### Bug Fixes -* **windows:** handle $0 better on Windows platforms ([eb6e03f](https://github.com/yargs/yargs/commit/eb6e03f)) +- **windows:** handle $0 better on Windows platforms ([eb6e03f](https://github.com/yargs/yargs/commit/eb6e03f)) ### Features -* **commands:** implemented variadic positional arguments ([51d926e](https://github.com/yargs/yargs/commit/51d926e)) -* **completion:** completion now better handles aliases, and avoids duplicating keys. ([86416c8](https://github.com/yargs/yargs/commit/86416c8)) -* **config:** If invoking .config() without parameters, set a default option ([0413dd1](https://github.com/yargs/yargs/commit/0413dd1)) -* **conventional-changelog:** switching to using conventional-changelog for generating the changelog ([a2b5a2a](https://github.com/yargs/yargs/commit/a2b5a2a)) - - +- **commands:** implemented variadic positional arguments ([51d926e](https://github.com/yargs/yargs/commit/51d926e)) +- **completion:** completion now better handles aliases, and avoids duplicating keys. ([86416c8](https://github.com/yargs/yargs/commit/86416c8)) +- **config:** If invoking .config() without parameters, set a default option ([0413dd1](https://github.com/yargs/yargs/commit/0413dd1)) +- **conventional-changelog:** switching to using conventional-changelog for generating the changelog ([a2b5a2a](https://github.com/yargs/yargs/commit/a2b5a2a)) ### v4.4.0 (2016/04/03 21:10 +07:00) @@ -1009,7 +857,7 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [#378](https://github.com/bcoe/yargs/pull/378) introduces the pkgConf feature, which tells yargs to load default argument values from a key on a project's package.json (@bcoe) - [#376](https://github.com/bcoe/yargs/pull/376) **breaking change**, make help() method signature - more consistent with other commands (@maxrimue) + more consistent with other commands (@maxrimue) - [#368](https://github.com/bcoe/yargs/pull/368) **breaking change**, overhaul to command handling API: introducing named positional arguments, commands as modules, introduces the concept of global options (options that don't reset). (@nexdrew, @bcoe). - [#364](https://github.com/bcoe/yargs/pull/364) add the slick new yargs website to the package.json (@iarna). @@ -1083,20 +931,25 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [#245](https://github.com/bcoe/yargs/pull/245) adds OSX CI testing (@bcoe, @nexdrew) ### v3.22.0 (2015/08/28 22:26 +00:00) + - [#242](https://github.com/bcoe/yargs/pull/242) adds detectLocale config option (@bcoe) ### v3.21.1 (2015/08/28 20:58 +00:00) + - [#240](https://github.com/bcoe/yargs/pull/240) hot-fix for Atom on Windows (@bcoe) ### v3.21.0 (2015/08/21 21:20 +00:00) + - [#238](https://github.com/bcoe/yargs/pull/238) upgrade camelcase, window-size, chai, mocha (@nexdrew) - [#237](https://github.com/bcoe/yargs/pull/237) adds defaultDescription to option() (@nexdrew) ### v3.20.0 (2015/08/20 01:29 +00:00) + - [#231](https://github.com/bcoe/yargs/pull/231) Merge pull request #231 from bcoe/detect-locale (@sindresorhus) - [#235](https://github.com/bcoe/yargs/pull/235) adds german translation to yargs (@maxrimue) ### v3.19.0 (2015/08/14 05:12 +00:00) + - [#224](https://github.com/bcoe/yargs/pull/224) added Portuguese translation (@codemonkey3045) ### v3.18.1 (2015/08/12 05:53 +00:00) @@ -1105,18 +958,22 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [#223](https://github.com/bcoe/yargs/pull/223) make booleans work in config files (@sgentle) ### v3.18.0 (2015/08/06 20:05 +00:00) + - [#222](https://github.com/bcoe/yargs/pull/222) updates fr locale (@nexdrew) - [#221](https://github.com/bcoe/yargs/pull/221) adds missing locale strings (@nexdrew) - [#220](https://github.com/bcoe/yargs/pull/220) adds es locale (@zkat) ### v3.17.1 (2015/08/02 19:35 +00:00) + - [#218](https://github.com/bcoe/yargs/pull/218) upgrades nyc (@bcoe) ### v3.17.0 (2015/08/02 18:39 +00:00) + - [#217](https://github.com/bcoe/yargs/pull/217) sort methods in README.md (@nexdrew) - [#215](https://github.com/bcoe/yargs/pull/215) adds fr locale (@LoicMahieu) ### v3.16.0 (2015/07/30 04:35 +00:00) + - [#210](https://github.com/bcoe/yargs/pull/210) adds i18n support to yargs (@bcoe) - [#209](https://github.com/bcoe/yargs/pull/209) adds choices type to yargs (@nexdrew) - [#207](https://github.com/bcoe/yargs/pull/207) pretty new shields from shields.io (@SimenB) @@ -1124,6 +981,7 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [#205](https://github.com/bcoe/yargs/pull/205) faster build times on Travis (@ChristianMurphy) ### v3.15.0 (2015/07/06 06:01 +00:00) + - [#197](https://github.com/bcoe/yargs/pull/197) tweaks to how errors bubble up from parser.js (@bcoe) - [#193](https://github.com/bcoe/yargs/pull/193) upgraded nyc, reporting now happens by default (@bcoe) @@ -1141,6 +999,7 @@ cript import to prevent a future major release warning ([#1441](https://www.gith default to filename completion (@tschaub) ### v3.12.0 (2015/06/19 03:23 +00:00) + - [#183](https://github.com/bcoe/yargs/pull/183) don't complete commands if they've already been completed (@tschaub) - [#181](https://github.com/bcoe/yargs/pull/181) various fixes for completion. (@bcoe, @tschaub) - [#182](https://github.com/bcoe/yargs/pull/182) you can now set a maximum # of of required arguments (@bcoe) @@ -1157,96 +1016,119 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [#164](https://github.com/bcoe/yargs/pull/164) better array handling thanks @getify (@bcoe) ### v3.9.1 (2015/05/20 05:14 +00:00) + - [b6662b6](https://github.com/bcoe/yargs/commit/b6662b6774cfeab4876f41ec5e2f67b7698f4e2f) clarify .config() docs (@linclark) - [0291360](https://github.com/bcoe/yargs/commit/02913606285ce31ce81d7f12c48d8a3029776ec7) fixed tests, switched to nyc for coverage, fixed security issue, added Lin as collaborator (@bcoe) ### v3.9.0 (2015/05/10 18:32 +00:00) + - [#157](https://github.com/bcoe/yargs/pull/157) Merge pull request #157 from bcoe/command-yargs. allows handling of command specific arguments. Thanks for the suggestion @ohjames (@bcoe) - [#158](https://github.com/bcoe/yargs/pull/158) Merge pull request #158 from kemitchell/spdx-license. Update license format (@kemitchell) ### v3.8.0 (2015/04/24 23:10 +00:00) + - [#154](https://github.com/bcoe/yargs/pull/154) showHelp's method signature was misleading fixes #153 (@bcoe) - [#151](https://github.com/bcoe/yargs/pull/151) refactor yargs' table layout logic to use new helper library (@bcoe) - [#150](https://github.com/bcoe/yargs/pull/150) Fix README example in argument requirements (@annonymouse) ### v3.7.2 (2015/04/13 11:52 -07:00) -* [679fbbf](https://github.com/bcoe/yargs/commit/679fbbf55904030ccee8a2635e8e5f46551ab2f0) updated yargs to use the [standard](https://github.com/feross/standard) style guide (agokjr) -* [22382ee](https://github.com/bcoe/yargs/commit/22382ee9f5b495bc2586c1758cd1091cec3647f9 various bug fixes for $0 (@nylen) +- [679fbbf](https://github.com/bcoe/yargs/commit/679fbbf55904030ccee8a2635e8e5f46551ab2f0) updated yargs to use the [standard](https://github.com/feross/standard) style guide (agokjr) +- [22382ee](https://github.com/bcoe/yargs/commit/22382ee9f5b495bc2586c1758cd1091cec3647f9 various bug fixes for $0 (@nylen) ### v3.7.1 (2015/04/10 11:06 -07:00) -* [89e1992](https://github.com/bcoe/yargs/commit/89e1992a004ba73609b5f9ee6890c4060857aba4) detect iojs bin along with node bin. (@bcoe) -* [755509e](https://github.com/bcoe/yargs/commit/755509ea90041e5f7833bba3b8c5deffe56f0aab) improvements to example documentation in README.md (@rstacruz) -* [0d2dfc8](https://github.com/bcoe/yargs/commit/0d2dfc822a43418242908ad97ddd5291a1b35dc6) showHelp() no longer requires that .argv has been called (@bcoe) +- [89e1992](https://github.com/bcoe/yargs/commit/89e1992a004ba73609b5f9ee6890c4060857aba4) detect iojs bin along with node bin. (@bcoe) +- [755509e](https://github.com/bcoe/yargs/commit/755509ea90041e5f7833bba3b8c5deffe56f0aab) improvements to example documentation in README.md (@rstacruz) +- [0d2dfc8](https://github.com/bcoe/yargs/commit/0d2dfc822a43418242908ad97ddd5291a1b35dc6) showHelp() no longer requires that .argv has been called (@bcoe) ### v3.7.0 (2015/04/04 02:29 -07:00) -* [56cbe2d](https://github.com/bcoe/yargs/commit/56cbe2ddd33dc176dcbf97ba40559864a9f114e4) make .requiresArg() work with type hints. (@bcoe). -* [2f5d562](https://github.com/bcoe/yargs/commit/2f5d5624f736741deeedf6a664d57bc4d857bdd0) serialize arrays and objects in usage strings. (@bcoe). -* [5126304](https://github.com/bcoe/yargs/commit/5126304dd18351fc28f10530616fdd9361e0af98) be more lenient about alias/primary key ordering in chaining API. (@bcoe) +- [56cbe2d](https://github.com/bcoe/yargs/commit/56cbe2ddd33dc176dcbf97ba40559864a9f114e4) make .requiresArg() work with type hints. (@bcoe). +- [2f5d562](https://github.com/bcoe/yargs/commit/2f5d5624f736741deeedf6a664d57bc4d857bdd0) serialize arrays and objects in usage strings. (@bcoe). +- [5126304](https://github.com/bcoe/yargs/commit/5126304dd18351fc28f10530616fdd9361e0af98) be more lenient about alias/primary key ordering in chaining API. (@bcoe) ### v3.6.0 (2015/03/21 01:00 +00:00) + - [4e24e22](https://github.com/bcoe/yargs/commit/4e24e22e6a195e55ab943ede704a0231ac33b99c) support for .js configuration files. (@pirxpilot) ### v3.5.4 (2015/03/12 05:56 +00:00) + - [c16cc08](https://github.com/bcoe/yargs/commit/c16cc085501155cf7fd853ccdf8584b05ab92b78) message for non-option arguments is now optional, thanks to (@raine) ### v3.5.3 (2015/03/09 06:14 +00:00) + - [870b428](https://github.com/bcoe/yargs/commit/870b428cf515d560926ca392555b7ad57dba9e3d) completion script was missing in package.json (@bcoe) ### v3.5.2 (2015/03/09 06:11 +00:00) + - [58a4b24](https://github.com/bcoe/yargs/commit/58a4b2473ebbb326713d522be53e32d3aabb08d2) parse was being called multiple times, resulting in strange behavior (@bcoe) ### v3.5.1 (2015/03/09 04:55 +00:00) + - [4e588e0](https://github.com/bcoe/yargs/commit/4e588e055afbeb9336533095f051496e3977f515) accidentally left testing logic in (@bcoe) ### v3.5.0 (2015/03/09 04:49 +00:00) + - [718bacd](https://github.com/bcoe/yargs/commit/718bacd81b9b44f786af76b2afe491fe06274f19) added support for bash completions see #4 (@bcoe) - [a192882](https://github.com/bcoe/yargs/commit/a19288270fc431396c42af01125eeb4443664528) downgrade to mocha 2.1.0 until https://github.com/mochajs/mocha/issues/1585 can be sorted out (@bcoe) ### v3.4.7 (2015/03/09 04:09 +00:00) + - [9845e5c](https://github.com/bcoe/yargs/commit/9845e5c1a9c684ba0be3f0bfb40e7b62ab49d9c8) the Argv singleton was not being updated when manually parsing arguments, fixes #114 (@bcoe) ### v3.4.6 (2015/03/09 04:01 +00:00) + - [45b4c80](https://github.com/bcoe/yargs/commit/45b4c80b890d02770b0a94f326695a8a566e8fe9) set placeholders for all keys fixes #115 (@bcoe) ### v3.4.5 (2015/03/01 20:31 +00:00) + - [a758e0b](https://github.com/bcoe/yargs/commit/a758e0b2556184f067cf3d9c4ef886d39817ebd2) fix for count consuming too many arguments (@bcoe) ### v3.4.4 (2015/02/28 04:52 +00:00) + - [0476af7](https://github.com/bcoe/yargs/commit/0476af757966acf980d998b45108221d4888cfcb) added nargs feature, allowing you to specify the number of arguments after an option (@bcoe) - [092477d](https://github.com/bcoe/yargs/commit/092477d7ab3efbf0ba11cede57f7d8cfc70b024f) updated README with full example of v3.0 API (@bcoe) ### v3.3.3 (2015/02/28 04:23 +00:00) + - [0c4b769](https://github.com/bcoe/yargs/commit/0c4b769516cd8d93a7c4e5e675628ae0049aa9a8) remove string dependency, which conflicted with other libraries see #106 (@bcoe) ### v3.3.2 (2015/02/28 04:11 +00:00) + - [2a98906](https://github.com/bcoe/yargs/commit/2a9890675821c0e7a12f146ce008b0562cb8ec9a) add $0 to epilog (@schnittstabil) ### v3.3.1 (2015/02/24 03:28 +00:00) + - [ad485ce](https://github.com/bcoe/yargs/commit/ad485ce748ebdfce25b88ef9d6e83d97a2f68987) fix for applying defaults to camel-case args (@bcoe) ### v3.3.0 (2015/02/24 00:49 +00:00) + - [8bfe36d](https://github.com/bcoe/yargs/commit/8bfe36d7fb0f93a799ea3f4c756a7467c320f8c0) fix and document restart() command, as a tool for building nested CLIs (@bcoe) ### v3.2.1 (2015/02/22 05:45 +00:00) + - [49a6d18](https://github.com/bcoe/yargs/commit/49a6d1822a4ef9b1ea6f90cc366be60912628885) you can now provide a function that generates a default value (@bcoe) ### v3.2.0 (2015/02/22 05:24 +00:00) + - [7a55886](https://github.com/bcoe/yargs/commit/7a55886c9343cf71a20744ca5cdd56d2ea7412d5) improvements to yargs two-column text layout (@bcoe) - [b6ab513](https://github.com/bcoe/yargs/commit/b6ab5136a4c3fa6aa496f6b6360382e403183989) Tweak NPM version badge (@nylen) ### v3.1.0 (2015/02/19 19:37 +00:00) + - [9bd2379](https://github.com/bcoe/yargs/commit/9bd237921cf1b61fd9f32c0e6d23f572fc225861) version now accepts a function, making it easy to load version #s from a package.json (@bcoe) ### v3.0.4 (2015/02/14 01:40 +00:00) + - [0b7c19b](https://github.com/bcoe/yargs/commit/0b7c19beaecb747267ca4cc10e5cb2a8550bc4b7) various fixes for dot-notation handling (@bcoe) ### v3.0.3 (2015/02/14 00:59 +00:00) + - [c3f35e9](https://github.com/bcoe/yargs/commit/c3f35e99bd5a0d278073fcadd95e2d778616cc17) make sure dot-notation is applied to aliases (@bcoe) ### 3.0.2 (2015/02/13 16:50 +00:00) + - [74c8967](https://github.com/bcoe/yargs/commit/74c8967c340c204a0a7edf8a702b6f46c2705435) document epilog shorthand of epilogue. (@bcoe) - [670110f](https://github.com/bcoe/yargs/commit/670110fc01bedc4831b6fec6afac54517d5a71bc) any non-truthy value now causes check to fail see #76 (@bcoe) - [0d8f791](https://github.com/bcoe/yargs/commit/0d8f791a33c11ced4cd431ea8d3d3a337d456b56) finished implementing my wish-list of fetures for yargs 3.0. see #88 (@bcoe) @@ -1256,27 +1138,34 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [4724cdf](https://github.com/bcoe/yargs/commit/4724cdfcc8e37ae1ca3dcce9d762f476e9ef4bb4) major refactor of index.js, in prep for 3.x release. (@bcoe) ### v2.3.0 (2015/02/08 20:41 +00:00) + - [d824620](https://github.com/bcoe/yargs/commit/d824620493df4e63664af1fe320764dd1a9244e6) allow for undefined boolean defaults (@ashi009) ### v2.2.0 (2015/02/08 20:07 +00:00) + - [d6edd98](https://github.com/bcoe/yargs/commit/d6edd9848826e7389ed1393858c45d03961365fd) in-prep for further refactoring, and a 3.x release I've shuffled some things around and gotten test-coverage to 100%. (@bcoe) ### v2.1.2 (2015/02/08 06:05 +00:00) + - [d640745](https://github.com/bcoe/yargs/commit/d640745a7b9f8d476e0223879d056d18d9c265c4) switch to path.relative (@bcoe) - [3bfd41f](https://github.com/bcoe/yargs/commit/3bfd41ff262a041f29d828b88936a79c63cad594) remove mocha.opts. (@bcoe) -- [47a2f35](https://github.com/bcoe/yargs/commit/47a2f357091db70903a402d6765501c1d63f15fe) document using .string('_') for string ids. see #56 (@bcoe) +- [47a2f35](https://github.com/bcoe/yargs/commit/47a2f357091db70903a402d6765501c1d63f15fe) document using .string('\_') for string ids. see #56 (@bcoe) - [#57](https://github.com/bcoe/yargs/pull/57) Merge pull request #57 from eush77/option-readme (@eush77) ### v2.1.1 (2015/02/06 08:08 +00:00) + - [01c6c61](https://github.com/bcoe/yargs/commit/01c6c61d67b4ebf88f41f0b32a345ec67f0ac17d) fix for #71, 'newAliases' of undefined (@bcoe) ### v2.1.0 (2015/02/06 07:59 +00:00) + - [6a1a3fa](https://github.com/bcoe/yargs/commit/6a1a3fa731958e26ccd56885f183dd8985cc828f) try to guess argument types, and apply sensible defaults see #73 (@bcoe) ### v2.0.1 (2015/02/06 07:54 +00:00) + - [96a06b2](https://github.com/bcoe/yargs/commit/96a06b2650ff1d085a52b7328d8bba614c20cc12) Fix for strange behavior with --sort option, see #51 (@bcoe) ### v2.0.0 (2015/02/06 07:45 +00:00) + - [0250517](https://github.com/bcoe/yargs/commit/0250517c9643e53f431b824e8ccfa54937414011) - [108fb84](https://github.com/bcoe/yargs/commit/108fb8409a3a63dcaf99d917fe4dfcfaa1de236d) fixed bug with boolean parsing, when bools separated by = see #66 (@bcoe) - [a465a59](https://github.com/bcoe/yargs/commit/a465a5915f912715738de890982e4f8395958b10) Add `files` field to the package.json (@shinnn) - [31043de](https://github.com/bcoe/yargs/commit/31043de7a38a17c4c97711f1099f5fb164334db3) fix for yargs.argv having the same keys added multiple times see #63 (@bcoe) @@ -1284,9 +1173,11 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [45da9ec](https://github.com/bcoe/yargs/commit/45da9ec4c55a7bd394721bc6a1db0dabad7bc52a) Mention .option in README (@eush77) ### v1.3.2 (2014/10/06 21:56 +00:00) + - [b8d3472](https://github.com/bcoe/yargs/commit/b8d34725482e5821a3cc809c0df71378f282f526) 1.3.2 (@chevex) ### list (2014/08/30 18:41 +00:00) + - [fbc777f](https://github.com/bcoe/yargs/commit/fbc777f416eeefd37c84e44d27d7dfc7c1925721) Now that yargs is the successor to optimist, I'm changing the README language to be more universal. Pirate speak isn't very accessible to non-native speakers. (@chevex) - [a54d068](https://github.com/bcoe/yargs/commit/a54d0682ae2efc2394d407ab171cc8a8bbd135ea) version output will not print extra newline (@boneskull) - [1cef5d6](https://github.com/bcoe/yargs/commit/1cef5d62a9d6d61a3948a49574892e01932cc6ae) Added contributors section to package.json (@chrisn) @@ -1309,52 +1200,68 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [ed5f6d3](https://github.com/bcoe/yargs/commit/ed5f6d33f57ad1086b11c91b51100f7c6c7fa8ee) Finished porting unit tests to Mocha. (@chevex) ### v1.0.15 (2014/02/05 23:18 +00:00) + - [e2b1fc0](https://github.com/bcoe/yargs/commit/e2b1fc0c4a59cf532ae9b01b275e1ef57eeb64d2) 1.0.15 update to badges (@chevex) ### v1.0.14 (2014/02/05 23:17 +00:00) + - [f33bbb0](https://github.com/bcoe/yargs/commit/f33bbb0f00fe18960f849cc8e15a7428a4cd59b8) Revert "Fixed issue which caused .demand function not to work correctly." (@chevex) ### v1.0.13 (2014/02/05 22:13 +00:00) + - [6509e5e](https://github.com/bcoe/yargs/commit/6509e5e7dee6ef1a1f60eea104be0faa1a045075) Fixed issue which caused .demand function not to work correctly. (@chevex) ### v1.0.12 (2013/12/13 00:09 +00:00) + - [05eb267](https://github.com/bcoe/yargs/commit/05eb26741c9ce446b33ff006e5d33221f53eaceb) 1.0.12 (@chevex) ### v1.0.11 (2013/12/13 00:07 +00:00) + - [c1bde46](https://github.com/bcoe/yargs/commit/c1bde46e37318a68b87d17a50c130c861d6ce4a9) 1.0.11 (@chevex) ### v1.0.10 (2013/12/12 23:57 +00:00) + - [dfebf81](https://github.com/bcoe/yargs/commit/dfebf8164c25c650701528ee581ca483a99dc21c) Fixed formatting in README (@chevex) ### v1.0.9 (2013/12/12 23:47 +00:00) + - [0b4e34a](https://github.com/bcoe/yargs/commit/0b4e34af5e6d84a9dbb3bb6d02cd87588031c182) Update README.md (@chevex) ### v1.0.8 (2013/12/06 16:36 +00:00) + - [#1](https://github.com/bcoe/yargs/pull/1) fix error caused by check() see #1 (@martinheidegger) ### v1.0.7 (2013/11/24 18:01 +00:00) + - [a247d88](https://github.com/bcoe/yargs/commit/a247d88d6e46644cbb7303c18b1bb678fc132d72) Modified Pirate Joe image. (@chevex) ### v1.0.6 (2013/11/23 19:21 +00:00) + - [d7f69e1](https://github.com/bcoe/yargs/commit/d7f69e1d34bc929736a8bdccdc724583e21b7eab) Updated Pirate Joe image. (@chevex) ### v1.0.5 (2013/11/23 19:09 +00:00) + - [ece809c](https://github.com/bcoe/yargs/commit/ece809cf317cc659175e1d66d87f3ca68c2760be) Updated readme notice again. (@chevex) ### v1.0.4 (2013/11/23 19:05 +00:00) + - [9e81e81](https://github.com/bcoe/yargs/commit/9e81e81654028f83ba86ffc3ac772a0476084e5e) Updated README with a notice about yargs being a fork of optimist and what that implies. (@chevex) ### v1.0.3 (2013/11/23 17:43 +00:00) + - [65e7a78](https://github.com/bcoe/yargs/commit/65e7a782c86764944d63d084416aba9ee6019c5f) Changed some small wording in README.md. (@chevex) - [459e20e](https://github.com/bcoe/yargs/commit/459e20e539b366b85128dd281ccd42221e96c7da) Fix a bug in the options function, when string and boolean options weren't applied to aliases. (@shockone) ### v1.0.2 (2013/11/23 09:46 +00:00) + - [3d80ebe](https://github.com/bcoe/yargs/commit/3d80ebed866d3799224b6f7d596247186a3898a9) 1.0.2 (@chevex) ### v1.0.1 (2013/11/23 09:39 +00:00) + - [f80ff36](https://github.com/bcoe/yargs/commit/f80ff3642d580d4b68bf9f5a94277481bd027142) Updated image. (@chevex) ### v1.0.0 (2013/11/23 09:33 +00:00) + - [54e31d5](https://github.com/bcoe/yargs/commit/54e31d505f820b80af13644e460894b320bf25a3) Rebranded from optimist to yargs in the spirit of the fork :D (@chevex) - [4ebb6c5](https://github.com/bcoe/yargs/commit/4ebb6c59f44787db7c24c5b8fe2680f01a23f498) Added documentation for demandCount(). (@chevex) - [4561ce6](https://github.com/bcoe/yargs/commit/4561ce66dcffa95f49e8b4449b25b94cd68acb25) Simplified the error messages returned by .check(). (@chevex) @@ -1379,11 +1286,12 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [d9bda11](https://github.com/bcoe/yargs/commit/d9bda1116e26f3b40e833ca9ca19263afea53565) Merge branch 'patch-1' of github.com:thefourtheye/node-optimist (@chevex) - [d6cc606](https://github.com/bcoe/yargs/commit/d6cc6064a4f1bea38a16a4430b8a1334832fbeff) Renamed README. (@chevex) - [9498d3f](https://github.com/bcoe/yargs/commit/9498d3f59acfb5e102826503e681623c3a64b178) Renamed readme and added .gitignore. (@chevex) -- [bbd1fe3](https://github.com/bcoe/yargs/commit/bbd1fe37fefa366dde0fb3dc44d91fe8b28f57f5) Included examples for ```help``` and ```showHelp``` functions and fixed few formatting issues (@thefourtheye) +- [bbd1fe3](https://github.com/bcoe/yargs/commit/bbd1fe37fefa366dde0fb3dc44d91fe8b28f57f5) Included examples for `help` and `showHelp` functions and fixed few formatting issues (@thefourtheye) - [37fea04](https://github.com/bcoe/yargs/commit/37fea0470a5796a0294c1dcfff68d8041650e622) .alias({}) behaves differently based on mapping direction when generating descriptions (@chbrown) - [855b20d](https://github.com/bcoe/yargs/commit/855b20d0be567ca121d06b30bea64001b74f3d6d) Documented function signatures are useful for dynamically typed languages. (@chbrown) ### 0.6.0 (2013/06/25 08:48 +00:00) + - [d37bfe0](https://github.com/bcoe/yargs/commit/d37bfe05ae6d295a0ab481efe4881222412791f4) all tests passing using minimist (@substack) - [76f1352](https://github.com/bcoe/yargs/commit/76f135270399d01f2bbc621e524a5966e5c422fd) all parse tests now passing (@substack) - [a7b6754](https://github.com/bcoe/yargs/commit/a7b6754276c38d1565479a5685c3781aeb947816) using minimist, some tests passing (@substack) @@ -1391,39 +1299,49 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [602a2a9](https://github.com/bcoe/yargs/commit/602a2a92a459f93704794ad51b115bbb08b535ce) v0.5.3 - Remove wordwrap as dependency (@DeadAlready) ### 0.5.2 (2013/05/31 03:46 +00:00) + - [4497ca5](https://github.com/bcoe/yargs/commit/4497ca55e332760a37b866ec119ded347ca27a87) fixed the whitespace bug without breaking anything else (@substack) - [5a3dd1a](https://github.com/bcoe/yargs/commit/5a3dd1a4e0211a38613c6e02f61328e1031953fa) failing test for whitespace arg (@substack) ### 0.5.1 (2013/05/30 07:17 +00:00) + - [a20228f](https://github.com/bcoe/yargs/commit/a20228f62a454755dd07f628a7c5759113918327) fix parse() to work with functions before it (@substack) - [b13bd4c](https://github.com/bcoe/yargs/commit/b13bd4cac856a9821d42fa173bdb58f089365a7d) failing test for parse() with modifiers (@substack) ### 0.5.0 (2013/05/18 21:59 +00:00) + - [c474a64](https://github.com/bcoe/yargs/commit/c474a649231527915c222156e3b40806d365a87c) fixes for dash (@substack) ### 0.4.0 (2013/04/13 19:03 +00:00) + - [dafe3e1](https://github.com/bcoe/yargs/commit/dafe3e18d7c6e7c2d68e06559df0e5cbea3adb14) failing short test (@substack) ### 0.3.7 (2013/04/04 04:07 +00:00) -- [6c7a0ec](https://github.com/bcoe/yargs/commit/6c7a0ec94ce4199a505f0518b4d6635d4e47cc81) Fix for windows. On windows there is no _ in environment. (@hdf) + +- [6c7a0ec](https://github.com/bcoe/yargs/commit/6c7a0ec94ce4199a505f0518b4d6635d4e47cc81) Fix for windows. On windows there is no \_ in environment. (@hdf) ### 0.3.6 (2013/04/04 04:04 +00:00) + - [e72346a](https://github.com/bcoe/yargs/commit/e72346a727b7267af5aa008b418db89970873f05) Add support for newlines in -a="" arguments (@danielbeardsley) - [71e1fb5](https://github.com/bcoe/yargs/commit/71e1fb55ea9987110a669ac6ec12338cfff3821c) drop 0.4, add 0.8 to travis (@substack) ### 0.3.5 (2012/10/10 11:09 +00:00) + - [ee692b3](https://github.com/bcoe/yargs/commit/ee692b37554c70a0bb16389a50a26b66745cbbea) Fix parsing booleans (@vojtajina) - [5045122](https://github.com/bcoe/yargs/commit/5045122664c3f5b4805addf1be2148d5856f7ce8) set $0 properly in the tests (@substack) ### 0.3.4 (2012/04/30 06:54 +00:00) + - [f28c0e6](https://github.com/bcoe/yargs/commit/f28c0e62ca94f6e0bb2e6d82fc3d91a55e69b903) bump for string "true" params (@substack) - [8f44aeb](https://github.com/bcoe/yargs/commit/8f44aeb74121ddd689580e2bf74ef86a605e9bf2) Fix failing test for aliased booleans. (@coderarity) - [b9f7b61](https://github.com/bcoe/yargs/commit/b9f7b613b1e68e11e6c23fbda9e555a517dcc976) Add failing test for short aliased booleans. (@coderarity) ### 0.3.3 (2012/04/30 06:45 +00:00) + - [541bac8](https://github.com/bcoe/yargs/commit/541bac8dd787a5f1a5d28f6d8deb1627871705e7) Fixes #37. ### 0.3.2 (2012/04/12 20:28 +00:00) + - [3a0f014](https://github.com/bcoe/yargs/commit/3a0f014c1451280ac1c9caa1f639d31675586eec) travis badge (@substack) - [4fb60bf](https://github.com/bcoe/yargs/commit/4fb60bf17845f4ce3293f8ca49c9a1a7c736cfce) Fix boolean aliases. (@coderarity) - [f14dda5](https://github.com/bcoe/yargs/commit/f14dda546efc4fe06ace04d36919bfbb7634f79b) Adjusted package.json to use tap (@jfhbrook) @@ -1431,12 +1349,15 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [e1e740c](https://github.com/bcoe/yargs/commit/e1e740c27082f3ce84deca2093d9db2ef735d0e5) two tests for combined boolean/alias opts parsing (@jfhbrook) ### 0.3.1 (2011/12/31 08:44 +00:00) + - [d09b719](https://github.com/bcoe/yargs/commit/d09b71980ef711b6cf3918cd19beec8257e40e82) If "default" is set to false it was not passed on, fixed. (@wolframkriesing) ### 0.3.0 (2011/12/09 06:03 +00:00) + - [6e74aa7](https://github.com/bcoe/yargs/commit/6e74aa7b46a65773e20c0cb68d2d336d4a0d553d) bump and documented dot notation (@substack) ### 0.2.7 (2011/10/20 02:25 +00:00) + - [94adee2](https://github.com/bcoe/yargs/commit/94adee20e17b58d0836f80e8b9cdbe9813800916) argv._ can be told 'Hey! argv._! Don't be messing with my args.', and it WILL obey (@colinta) - [c46fdd5](https://github.com/bcoe/yargs/commit/c46fdd56a05410ae4a1e724a4820c82e77ff5469) optimistic critter image (@substack) - [5c95c73](https://github.com/bcoe/yargs/commit/5c95c73aedf4c7482bd423e10c545e86d7c8a125) alias options() to option() (@substack) @@ -1488,7 +1409,7 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [dff6d07](https://github.com/bcoe/yargs/commit/dff6d078d97f8ac503c7d18dcc7b7a8c364c2883) boolean examples (@substack) - [0e380b9](https://github.com/bcoe/yargs/commit/0e380b92c4ef4e3c8dac1da18b5c31d85b1d02c9) boolean() with passing test (@substack) - [62644d4](https://github.com/bcoe/yargs/commit/62644d4bffbb8d1bbf0c2baf58a1d14a6359ef07) coffee compatibility with node regex for versions too (@substack) -- [430fafc](https://github.com/bcoe/yargs/commit/430fafcf1683d23774772826581acff84b456827) argv._ fixed by fixing the coffee detection (@substack) +- [430fafc](https://github.com/bcoe/yargs/commit/430fafcf1683d23774772826581acff84b456827) argv.\_ fixed by fixing the coffee detection (@substack) - [343b8af](https://github.com/bcoe/yargs/commit/343b8afefd98af274ebe21b5a16b3a949ec5429f) whichNodeArgs test fails too (@substack) - [63df2f3](https://github.com/bcoe/yargs/commit/63df2f371f31e63d7f1dec2cbf0022a5f08da9d2) replicated mnot's bug in whichNodeEmpty test (@substack) - [35473a4](https://github.com/bcoe/yargs/commit/35473a4d93a45e5e7e512af8bb54ebb532997ae1) test for ./bin usage (@substack) @@ -1510,7 +1431,7 @@ cript import to prevent a future major release warning ([#1441](https://www.gith - [a4843a9](https://github.com/bcoe/yargs/commit/a4843a9f0e69ffb4afdf6a671d89eb6f218be35d) check bug fixed plus a handy string (@substack) - [857bd2d](https://github.com/bcoe/yargs/commit/857bd2db933a5aaa9cfecba0ced2dc9b415f8111) tests for demandCount, back up to 100% coverage (@substack) - [073b776](https://github.com/bcoe/yargs/commit/073b7768ebd781668ef05c13f9003aceca2f5c35) call demandCount from demand (@substack) -- [4bd4b7a](https://github.com/bcoe/yargs/commit/4bd4b7a085c8b6ce1d885a0f486cc9865cee2db1) add demandCount to check for the number of arguments in the _ list (@marshall) +- [4bd4b7a](https://github.com/bcoe/yargs/commit/4bd4b7a085c8b6ce1d885a0f486cc9865cee2db1) add demandCount to check for the number of arguments in the \_ list (@marshall) - [b8689ac](https://github.com/bcoe/yargs/commit/b8689ac68dacf248119d242bba39a41cb0adfa07) Rebase checks. That will be its own module eventually. (@substack) - [e688370](https://github.com/bcoe/yargs/commit/e688370b576f0aa733c3f46183df69e1b561668e) a $0 like in perl (@substack) - [2e5e196](https://github.com/bcoe/yargs/commit/2e5e1960fc19afb21fb3293752316eaa8bcd3609) usage test hacking around process and console (@substack) diff --git a/docs/advanced.md b/docs/advanced.md index a2cce2518..d190d0a7b 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -1,6 +1,7 @@ # Advanced Topics + ## Commands Yargs provides a powerful set of tools for composing modular command-driven-applications. @@ -14,11 +15,14 @@ commands. tldr; default commands allow you to define the entry point to your application using a similar API to subcommands. ```js -const argv = require('yargs/yargs')(process.argv.slice(2)) - .command('$0', 'the default command', () => {}, (argv) => { - console.log('this command will be run by default') - }) - .argv +const argv = require('yargs/yargs')(process.argv.slice(2)).command( + '$0', + 'the default command', + () => {}, + argv => { + console.log('this command will be run by default'); + } +).argv; ``` The command defined above will be executed if the program @@ -27,11 +31,14 @@ is run with `./my-cli.js --x=22`. Default commands can also be used as a command alias, like so: ```js -const argv = require('yargs/yargs')(process.argv.slice(2)) - .command(['serve', '$0'], 'the serve command', () => {}, (argv) => { - console.log('this command will be run by default') - }) - .argv +const argv = require('yargs/yargs')(process.argv.slice(2)).command( + ['serve', '$0'], + 'the serve command', + () => {}, + argv => { + console.log('this command will be run by default'); + } +).argv; ``` The command defined above will be executed if the program @@ -45,9 +52,7 @@ take the form `[bar]`. The parsed positional arguments will be populated in `argv`: ```js -yargs.command('get [proxy]', 'make a get HTTP request') - .help() - .argv +yargs.command('get [proxy]', 'make a get HTTP request').help().argv; ``` #### Positional Argument Aliases @@ -57,9 +62,12 @@ As an example, suppose our application allows either a username _or_ an email as the first argument: ```js -yargs.command('get [password]', 'fetch a user by username or email.') - .help() - .argv +yargs + .command( + 'get [password]', + 'fetch a user by username or email.' + ) + .help().argv; ``` In this way, both `argv.username` and `argv.email` would be populated with the @@ -71,9 +79,7 @@ The last positional argument can optionally accept an array of values, by using the `..` operator: ```js -yargs.command('download [files..]', 'download several files') - .help() - .argv +yargs.command('download [files..]', 'download several files').help().argv; ``` #### Describing Positional Arguments @@ -81,17 +87,19 @@ yargs.command('download [files..]', 'download several files') You can use the method [`.positional()`](/docs/api.md#positionalkey-opt) in a command's builder function to describe and configure a positional argument: ```js -yargs.command('get [proxy]', 'make a get HTTP request', (yargs) => { - yargs.positional('source', { - describe: 'URL to fetch content from', - type: 'string', - default: 'http://www.google.com' - }).positional('proxy', { - describe: 'optional proxy URL' +yargs + .command('get [proxy]', 'make a get HTTP request', yargs => { + yargs + .positional('source', { + describe: 'URL to fetch content from', + type: 'string', + default: 'http://www.google.com', + }) + .positional('proxy', { + describe: 'optional proxy URL', + }); }) -}) -.help() -.argv + .help().argv; ``` ### Command Execution @@ -125,22 +133,21 @@ line, the command will be executed. ```js #!/usr/bin/env node require('yargs/yargs')(process.argv.slice(2)) - .command(['start [app]', 'run', 'up'], 'Start up an app', {}, (argv) => { - console.log('starting up the', argv.app || 'default', 'app') + .command(['start [app]', 'run', 'up'], 'Start up an app', {}, argv => { + console.log('starting up the', argv.app || 'default', 'app'); }) .command({ command: 'configure [value]', aliases: ['config', 'cfg'], desc: 'Set a config variable', - builder: (yargs) => yargs.default('value', 'true'), - handler: (argv) => { - console.log(`setting ${argv.key} to ${argv.value}`) - } + builder: yargs => yargs.default('value', 'true'), + handler: argv => { + console.log(`setting ${argv.key} to ${argv.value}`); + }, }) .demandCommand() .help() - .wrap(72) - .argv + .wrap(72).argv; ``` ``` @@ -164,47 +171,49 @@ starting up the web app For complicated commands you can pull the logic into a module. A module simply needs to export: -* `exports.command`: string (or array of strings) that executes this command when given on the command line, first string may contain positional args -* `exports.aliases`: array of strings (or a single string) representing aliases of `exports.command`, positional args defined in an alias are ignored -* `exports.describe`: string used as the description for the command in help text, use `false` for a hidden command -* `exports.builder`: object declaring the options the command accepts, or a function accepting and returning a yargs instance -* `exports.handler`: a function which will be passed the parsed argv. -* `exports.deprecated`: a boolean (or string) to show deprecation notice. +- `exports.command`: string (or array of strings) that executes this command when given on the command line, first string may contain positional args +- `exports.aliases`: array of strings (or a single string) representing aliases of `exports.command`, positional args defined in an alias are ignored +- `exports.describe`: string used as the description for the command in help text, use `false` for a hidden command +- `exports.builder`: object declaring the options the command accepts, or a function accepting and returning a yargs instance +- `exports.handler`: a function which will be passed the parsed argv. +- `exports.deprecated`: a boolean (or string) to show deprecation notice. ```js // my-module.js -exports.command = 'get [proxy]' +exports.command = 'get [proxy]'; -exports.describe = 'make a get HTTP request' +exports.describe = 'make a get HTTP request'; exports.builder = { banana: { - default: 'cool' + default: 'cool', }, batman: { - default: 'sad' - } -} + default: 'sad', + }, +}; exports.handler = function (argv) { // do something with argv. -} +}; ``` You then register the module like so: ```js -yargs.command(require('my-module')) - .help() - .argv +yargs.command(require('my-module')).help().argv; ``` Or if the module does not export `command` and `describe` (or if you just want to override them): ```js -yargs.command('get [proxy]', 'make a get HTTP request', require('my-module')) - .help() - .argv +yargs + .command( + 'get [proxy]', + 'make a get HTTP request', + require('my-module') + ) + .help().argv; ``` #### Testing a Command Module @@ -212,26 +221,25 @@ yargs.command('get [proxy]', 'make a get HTTP request', require('my-mod If you want to test a command in its entirety you can test it like this: ```js -it("returns help output", async () => { +it('returns help output', async () => { // Initialize parser using the command module const parser = yargs.command(require('./my-command-module')).help(); // Run the command module with --help as argument - const output = await new Promise((resolve) => { - parser.parse("--help", (err, argv, output) => { + const output = await new Promise(resolve => { + parser.parse('--help', (err, argv, output) => { resolve(output); - }) + }); }); // Verify the output is correct - expect(output).toBe(expect.stringContaining("helpful message")); + expect(output).toBe(expect.stringContaining('helpful message')); }); ``` This example uses [jest](https://github.com/facebook/jest) as a test runner, but the concept is independent of framework. -.commandDir(directory, [opts]) ------------------------------- +## .commandDir(directory, [opts]) _Note: `commandDir()` does not work with ESM or Deno, see [hierarchy using index.mjs](/docs/advanced.md#esm-hierarchy) for an example of building a complex nested CLI using ESM._ @@ -256,26 +264,26 @@ can either move your module to a different directory or use the `exclude` or - `recurse`: boolean, default `false` - Look for command modules in all subdirectories and apply them as a flattened - (non-hierarchical) list. + Look for command modules in all subdirectories and apply them as a flattened + (non-hierarchical) list. - `extensions`: array of strings, default `['js']` - The types of files to look for when requiring command modules. + The types of files to look for when requiring command modules. - `visit`: function - A synchronous function called for each command module encountered. Accepts - `commandObject`, `pathToFile`, and `filename` as arguments. Returns - `commandObject` to include the command; any falsy value to exclude/skip it. + A synchronous function called for each command module encountered. Accepts + `commandObject`, `pathToFile`, and `filename` as arguments. Returns + `commandObject` to include the command; any falsy value to exclude/skip it. - `include`: RegExp or function - Allow list certain modules. See [`require-directory`](https://www.npmjs.com/package/require-directory) for details. + Allow list certain modules. See [`require-directory`](https://www.npmjs.com/package/require-directory) for details. - `exclude`: RegExp or function - Block list certain modules. See [`require-directory`](https://www.npmjs.com/package/require-directory) for details. + Block list certain modules. See [`require-directory`](https://www.npmjs.com/package/require-directory) for details. ### Example command hierarchy using `.commandDir()` @@ -310,59 +318,62 @@ cli.js: require('yargs/yargs')(process.argv.slice(2)) .commandDir('cmds') .demandCommand() - .help() - .argv + .help().argv; ``` cmds/init.js: ```js -exports.command = 'init [dir]' -exports.desc = 'Create an empty repo' +exports.command = 'init [dir]'; +exports.desc = 'Create an empty repo'; exports.builder = { dir: { - default: '.' - } -} + default: '.', + }, +}; exports.handler = function (argv) { - console.log('init called for dir', argv.dir) -} + console.log('init called for dir', argv.dir); +}; ``` cmds/remote.js: ```js -exports.command = 'remote ' -exports.desc = 'Manage set of tracked repos' +exports.command = 'remote '; +exports.desc = 'Manage set of tracked repos'; exports.builder = function (yargs) { - return yargs.commandDir('remote_cmds') -} -exports.handler = function (argv) {} + return yargs.commandDir('remote_cmds'); +}; +exports.handler = function (argv) {}; ``` cmds/remote_cmds/add.js: ```js -exports.command = 'add ' -exports.desc = 'Add remote named for repo at url ' -exports.builder = {} +exports.command = 'add '; +exports.desc = 'Add remote named for repo at url '; +exports.builder = {}; exports.handler = function (argv) { - console.log('adding remote %s at url %s', argv.name, argv.url) -} + console.log('adding remote %s at url %s', argv.name, argv.url); +}; ``` cmds/remote_cmds/prune.js: ```js -exports.command = 'prune [names..]' -exports.desc = 'Delete tracked branches gone stale for remotes' -exports.builder = {} +exports.command = 'prune [names..]'; +exports.desc = 'Delete tracked branches gone stale for remotes'; +exports.builder = {}; exports.handler = function (argv) { - console.log('pruning remotes %s', [].concat(argv.name).concat(argv.names).join(', ')) -} + console.log( + 'pruning remotes %s', + [].concat(argv.name).concat(argv.names).join(', ') + ); +}; ``` + ### Example command hierarchy using index.mjs To support creating a complex nested CLI when using ESM, the method @@ -386,15 +397,14 @@ cli.js: #!/usr/bin/env node import yargs from 'yargs'; -import { hideBin } from 'yargs/helpers'; -import { commands } from './cmds/index.mjs'; +import {hideBin} from 'yargs/helpers'; +import {commands} from './cmds/index.mjs'; -yargs(hideBin(process.argv)) - .command(commands) - .argv; +yargs(hideBin(process.argv)).command(commands).argv; ``` + ## Building Configurable CLI Apps One of the goals of yargs has been to examine practices common in the @@ -409,17 +419,15 @@ allow users to extend and customize their functionality. It's common for libraries, e.g., [Babel](https://babeljs.io/docs/usage/babelrc/), [ESLint](https://github.com/eslint/eslint#configuration), to allow you to provide configuration by populating a `.rc` file. -Yargs' [`config()`](/docs/api.md#config), combined with the module [find-up](https://www.npmjs.com/package/find-up), makes it easy to +Yargs' [`config()`](/docs/api.md#config), combined with the module [find-up](https://www.npmjs.com/package/find-up), makes it easy to implement `.rc` functionality: ```js -const findUp = require('find-up') -const fs = require('fs') -const configPath = findUp.sync(['.myapprc', '.myapprc.json']) -const config = configPath ? JSON.parse(fs.readFileSync(configPath)) : {} -const argv = require('yargs/yargs')(process.argv.slice(2)) - .config(config) - .argv +const findUp = require('find-up'); +const fs = require('fs'); +const configPath = findUp.sync(['.myapprc', '.myapprc.json']); +const config = configPath ? JSON.parse(fs.readFileSync(configPath)) : {}; +const argv = require('yargs/yargs')(process.argv.slice(2)).config(config).argv; ``` ### Providing Configuration in Your package.json @@ -445,9 +453,7 @@ Yargs gives you this functionality using the [`pkgConf()`](/docs/api.md#config) method: ```js -const argv = require('yargs/yargs')(process.argv.slice(2)) - .pkgConf('nyc') - .argv +const argv = require('yargs/yargs')(process.argv.slice(2)).pkgConf('nyc').argv; ``` ### Creating a Plugin Architecture @@ -465,6 +471,7 @@ possible to build plugin architectures similar to [Babel's presets](https://babe ``` + ## Customizing Yargs' Parser Not everyone always agrees on how `process.argv` should be interpreted; @@ -472,13 +479,13 @@ using the [`parserConfiguration()`](/docs/api.md#parserConfiguration) method you ```js yargs.parserConfiguration({ - "short-option-groups": true, - "camel-case-expansion": true, - "dot-notation": true, - "parse-numbers": true, - "boolean-negation": true, - "deep-merge-config": false -}) + 'short-option-groups': true, + 'camel-case-expansion': true, + 'dot-notation': true, + 'parse-numbers': true, + 'boolean-negation': true, + 'deep-merge-config': false, +}); ``` See the [yargs-parser](https://github.com/yargs/yargs-parser#configuration) module @@ -506,16 +513,16 @@ In this example, our middleware will check if the `username` and `password` is p #### Middleware function ```js -const normalizeCredentials = (argv) => { +const normalizeCredentials = argv => { if (!argv.username || !argv.password) { - const credentials = JSON.parse(fs.readSync('~/.credentials')) - return credentials + const credentials = JSON.parse(fs.readSync('~/.credentials')); + return credentials; } - return {} -} + return {}; +}; // Add normalizeCredentials to yargs -yargs.middleware(normalizeCredentials) +yargs.middleware(normalizeCredentials); ``` ### Example Async Credentials Middleware @@ -525,18 +532,18 @@ This example is exactly the same however it loads the `username` and `password` #### Middleware function ```js -const { promisify } = require('util') // since node 8.0.0 -const readFile = promisify(require('fs').readFile) +const {promisify} = require('util'); // since node 8.0.0 +const readFile = promisify(require('fs').readFile); -const normalizeCredentials = (argv) => { +const normalizeCredentials = argv => { if (!argv.username || !argv.password) { - return readFile('~/.credentials').then(data => JSON.parse(data)) + return readFile('~/.credentials').then(data => JSON.parse(data)); } - return {} -} + return {}; +}; // Add normalizeCredentials to yargs -yargs.middleware(normalizeCredentials) +yargs.middleware(normalizeCredentials); ``` #### yargs parsing configuration @@ -544,15 +551,17 @@ yargs.middleware(normalizeCredentials) ```js var argv = require('yargs/yargs')(process.argv.slice(2)) .usage('Usage: $0 [options]') - .command('login', 'Authenticate user', (yargs) =>{ - return yargs.option('username') - .option('password') - } ,(argv) => { - authenticateUser(argv.username, argv.password) - }, - [normalizeCredentials] - ) - .argv; + .command( + 'login', + 'Authenticate user', + yargs => { + return yargs.option('username').option('password'); + }, + argv => { + authenticateUser(argv.username, argv.password); + }, + [normalizeCredentials] + ).argv; ``` ## Using Yargs with Async/await @@ -562,25 +571,31 @@ If you use async middleware or async builders/handlers for commands, `yargs.pars parsed arguments object will be returned after the handler completes: ```js -import yargs from 'yargs' -import { hideBin } from 'yargs/helpers' +import yargs from 'yargs'; +import {hideBin} from 'yargs/helpers'; async function processValue(value) { - return new Promise((resolve) => { + return new Promise(resolve => { // Perform some async operation on value. setTimeout(() => { - return resolve(value) - }, 1000) - }) + return resolve(value); + }, 1000); + }); } -console.info('start') +console.info('start'); await yargs(hideBin(process.argv)) - .command('add ', 'add two eventual values', () => {}, async (argv) => { - const sum = await processValue(argv.x) + await processValue(argv.y) - console.info(`x + y = ${sum}`) - }).parse() -console.info('finish') + .command( + 'add ', + 'add two eventual values', + () => {}, + async argv => { + const sum = (await processValue(argv.x)) + (await processValue(argv.y)); + console.info(`x + y = ${sum}`); + } + ) + .parse(); +console.info('finish'); ``` ### Handling async errors @@ -591,29 +606,34 @@ Use `try`/`catch` to perform error handling, you can do so by setting `.fail(false)`: ```js -import yargs from 'yargs' -import { hideBin } from 'yargs/helpers' +import yargs from 'yargs'; +import {hideBin} from 'yargs/helpers'; async function processValue(value) { return new Promise((resolve, reject) => { // Perform some async operation on value. setTimeout(() => { - return reject(Error('something went wrong')) - }, 1000) - }) + return reject(Error('something went wrong')); + }, 1000); + }); } -console.info('start') +console.info('start'); const parser = yargs(hideBin(process.argv)) - .command('add ', 'add two eventual values', () => {}, async (argv) => { - const sum = await processValue(argv.x) + await processValue(argv.y) - console.info(`x + y = ${sum}`) - }) - .fail(false) + .command( + 'add ', + 'add two eventual values', + () => {}, + async argv => { + const sum = (await processValue(argv.x)) + (await processValue(argv.y)); + console.info(`x + y = ${sum}`); + } + ) + .fail(false); try { const argv = await parser.parse(); } catch (err) { - console.info(`${err.message}\n ${await parser.getHelp()}`) + console.info(`${err.message}\n ${await parser.getHelp()}`); } -console.info('finish') +console.info('finish'); ``` diff --git a/docs/api.md b/docs/api.md index 2762bb04d..66ac7255c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,5 +1,4 @@ -Additional documentation -=== +# Additional documentation For more details refer to the official [API reference](https://yargs.js.org/docs/#api-reference) document on the yargs.js.org website. @@ -14,33 +13,31 @@ This document is the Yargs API reference. There are more documentation files in - [Bundling](https://github.com/yargs/yargs/blob/main/docs/bundling.md) - [Parsing Tricks](https://github.com/yargs/yargs/blob/main/docs/tricks.md) - -API reference -=== +# API reference You can pass Yargs the `process.argv` without any additional configuration and it will do its best to parse it into an object: ```javascript -require('yargs/yargs')(process.argv.slice(2)).argv +require('yargs/yargs')(process.argv.slice(2)).argv; ``` You can also pass in an arbitrary array of arguments: ```javascript -require('yargs/yargs')([ '-x', '1', '-y', '2' ]).argv +require('yargs/yargs')(['-x', '1', '-y', '2']).argv; ``` or use `.parse()` to do the same thing: ```javascript -require('yargs/yargs')().parse([ '-x', '1', '-y', '2' ]) +require('yargs/yargs')().parse(['-x', '1', '-y', '2']); ``` Calling `.parse()` with no arguments is equivalent to calling `.argv`: ```javascript -require('yargs/yargs')(process.argv.slice(2)).parse() +require('yargs/yargs')(process.argv.slice(2)).parse(); ``` When passing in the arguments yourself, note that Yargs expects the passed array @@ -51,19 +48,18 @@ starts with two extra elements:`process.execPath` and the path to the JavaScript file being executed. So if you’re getting your arguments from `process.argv` in Node, pass `process.argv.slice(2)` to Yargs. -***Note:*** Yargs exposes the helper `hideBin`, which handles the +**_Note:_** Yargs exposes the helper `hideBin`, which handles the `process.argv.slice` logic for you. ```javascript -const { hideBin } = require('yargs/helpers') -const argv = yargs(hideBin(process.argv)).argv +const {hideBin} = require('yargs/helpers'); +const argv = yargs(hideBin(process.argv)).argv; ``` The rest of these methods below come in just before the terminating `.argv` or terminating `.parse()`. -.alias(key, alias) ------------------- +## .alias(key, alias) Set key names as equivalent such that updates to a key will propagate to aliases and vice-versa. @@ -72,8 +68,7 @@ Optionally `.alias()` can take an object that maps keys to aliases. Each key of this object should be the canonical version of the option, and each value should be a string or an array of strings. -.argv ------ +## .argv Get the arguments as a plain old object. @@ -87,10 +82,9 @@ If `yargs` is executed in an environment that embeds node and there's no script expects it to be the script name. In order to override this behavior, use `.parse(process.argv.slice(1))` instead of `.argv` and the first parameter won't be ignored. -***Note:*** `.argv` should only be used at the top level, not inside a command's builder function. +**_Note:_** `.argv` should only be used at the top level, not inside a command's builder function. -.array(key) ----------- +## .array(key) Tell the parser to interpret `key` as an array. If `.array('foo')` is set, `--foo foo bar` will be parsed as `['foo', 'bar']` rather than as `'foo'`. @@ -100,6 +94,7 @@ so `--foo foo --foo bar` will be parsed as `['foo', 'bar']` When the option is used with a positional, use `--` to tell `yargs` to stop adding values to the array. For example: `--foo foo bar -- val` will be parsed as + ```javascript { _: ['val'], @@ -107,8 +102,7 @@ For example: `--foo foo bar -- val` will be parsed as } ``` -.boolean(key) -------------- +## .boolean(key) Interpret `key` as a boolean. If a non-flag option - unless `true` or `false` - follows `key` in `process.argv`, that string won't get set as the value of `key`. @@ -116,8 +110,7 @@ Interpret `key` as a boolean. If a non-flag option - unless `true` or `false` - If `key` is an array, interpret all the elements as booleans. -.check(fn, [global=true]) ----------- +## .check(fn, [global=true]) Check that certain conditions are met in the provided arguments. @@ -132,20 +125,19 @@ used to prevent Yargs from exiting after a failed check. at the top-level and for each sub-command. ```js -const argv = require('yargs/yargs')(process.argv.slice(2)) - .check((argv, options) => { - const filePaths = argv._ +const argv = require('yargs/yargs')(process.argv.slice(2)).check( + (argv, options) => { + const filePaths = argv._; if (filePaths.length > 1) { - throw new Error("Only 0 or 1 files may be passed.") + throw new Error('Only 0 or 1 files may be passed.'); } else { - return true // tell Yargs that the arguments passed the check + return true; // tell Yargs that the arguments passed the check } - }) - .argv + } +).argv; ``` -.choices(key, choices) ----------------------- +## .choices(key, choices) Limit valid values for `key` to a predefined set of `choices`, given as an array or as an individual value. @@ -155,8 +147,7 @@ var argv = require('yargs/yargs')(process.argv.slice(2)) .alias('i', 'ingredient') .describe('i', 'choose your sandwich ingredients') .choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles']) - .help('help') - .argv + .help('help').argv; ``` If this method is called multiple times, all enumerated values will be merged @@ -169,17 +160,14 @@ choices. Choices can also be specified as `choices` in the object given to `option()`. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .option('size', { - alias: 's', - describe: 'choose a size', - choices: ['xs', 's', 'm', 'l', 'xl'] - }) - .argv +var argv = require('yargs/yargs')(process.argv.slice(2)).option('size', { + alias: 's', + describe: 'choose a size', + choices: ['xs', 's', 'm', 'l', 'xl'], +}).argv; ``` -.coerce(key, fn) ----------------- +## .coerce(key, fn) Provide a function to coerce or transform the value(s) given on the command line for `key`. @@ -198,10 +186,10 @@ all other modifications, such as [`.normalize()`](#normalize). _Examples:_ ```js -import { readFile } from 'node:fs/promises'; +import {readFile} from 'node:fs/promises'; import yargs from 'yargs'; const argv = await yargs(process.argv.slice(2)) - .coerce('file', async (arg) => { + .coerce('file', async arg => { const content = await readFile(arg, 'utf8'); return JSON.parse(content); }) @@ -212,21 +200,20 @@ Optionally `.coerce()` can take an object that maps several keys to their respective coercion function. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .coerce({ - date: Date.parse, - json: JSON.parse - }) - .argv +var argv = require('yargs/yargs')(process.argv.slice(2)).coerce({ + date: Date.parse, + json: JSON.parse, +}).argv; ``` You can also map the same function to several keys at one time. Just pass an array of keys as the first argument to `.coerce()`: ```js -var path = require('path') -var argv = require('yargs/yargs')(process.argv.slice(2)) - .coerce(['src', 'dest'], path.resolve) - .argv +var path = require('path'); +var argv = require('yargs/yargs')(process.argv.slice(2)).coerce( + ['src', 'dest'], + path.resolve +).argv; ``` If you are using dot-notion or arrays, .e.g., `user.email` and `user.password`, coercion will be applied to the final object that has been parsed: @@ -237,16 +224,16 @@ If you are using dot-notion or arrays, .e.g., `user.email` and `user.password`, var argv = require('yargs/yargs')(process.argv.slice(2)) .option('user') .coerce('user', opt => { - opt.name = opt.name.toLowerCase() - opt.password = '[SECRET]' - return opt - }) - .argv + opt.name = opt.name.toLowerCase(); + opt.password = '[SECRET]'; + return opt; + }).argv; ``` .commandDir(directory, [opts]) ------------------------------- + +--- Apply command modules from a directory relative to the module calling this method. @@ -269,11 +256,12 @@ to include the command; any falsy value to exclude/skip it. .command(cmd, desc, [builder], [handler]) ------------------------------------------ -.command(cmd, desc, [module]) ------------------------------ -.command(module) ----------------- + +--- + +## .command(cmd, desc, [module]) + +## .command(module) Define the commands exposed by your application. @@ -282,7 +270,7 @@ representing the command and its aliases. Read more about command aliases in the subsection below. Use `desc` to provide a description for each command your application accepts (the -values stored in `argv._`). Set `desc` to `false` to create a hidden command. +values stored in `argv._`). Set `desc` to `false` to create a hidden command. Hidden commands don't show up in the help output and aren't available for completion. @@ -294,11 +282,10 @@ yargs .command('get', 'make a get HTTP request', { url: { alias: 'u', - default: 'http://yargs.js.org/' - } + default: 'http://yargs.js.org/', + }, }) - .help() - .argv + .help().argv; ``` `builder` can also be a function. This function is executed @@ -309,14 +296,17 @@ builder. ```js yargs - .command('get', 'make a get HTTP request', function (yargs, helpOrVersionSet) { - return yargs.option('url', { - alias: 'u', - default: 'http://yargs.js.org/' - }) - }) - .help() - .argv + .command( + 'get', + 'make a get HTTP request', + function (yargs, helpOrVersionSet) { + return yargs.option('url', { + alias: 'u', + default: 'http://yargs.js.org/', + }); + } + ) + .help().argv; ``` You can also provide a handler function, which will be executed with the @@ -330,24 +320,22 @@ yargs function (yargs) { return yargs.option('u', { alias: 'url', - describe: 'the URL to make an HTTP request to' - }) + describe: 'the URL to make an HTTP request to', + }); }, function (argv) { - console.log(argv.url) + console.log(argv.url); } ) - .help() - .argv + .help().argv; ``` -***Note:*** `.parse()` and `.argv` should only be used at the top level, not inside a command's builder function. +**_Note:_** `.parse()` and `.argv` should only be used at the top level, not inside a command's builder function. Please see [Advanced Topics: Commands](https://github.com/yargs/yargs/blob/main/docs/advanced.md#commands) for a thorough discussion of the advanced features exposed in the Command API. -.completion([cmd], [description], [fn]) ---------------------------------------- +## .completion([cmd], [description], [fn]) Enable bash/zsh-completion shortcuts for commands and options. @@ -366,73 +354,70 @@ If invoked without parameters, `.completion()` will make `completion` the comman the completion script. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .completion('completion', function(current, argv) { +var argv = require('yargs/yargs')(process.argv.slice(2)).completion( + 'completion', + function (current, argv) { // 'current' is the current command being completed. // 'argv' is the parsed arguments so far. // simply return an array of completions. - return [ - 'foo', - 'bar' - ]; - }) - .argv; + return ['foo', 'bar']; + } +).argv; ``` You can also provide asynchronous completions. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .completion('completion', function(current, argv, done) { - setTimeout(function() { - done([ - 'apple', - 'banana' - ]); +var argv = require('yargs/yargs')(process.argv.slice(2)).completion( + 'completion', + function (current, argv, done) { + setTimeout(function () { + done(['apple', 'banana']); }, 500); - }) - .argv; + } +).argv; ``` But wait, there's more! You can return an asynchronous promise. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .completion('completion', function(current, argv) { +var argv = require('yargs/yargs')(process.argv.slice(2)).completion( + 'completion', + function (current, argv) { return new Promise(function (resolve, reject) { setTimeout(function () { - resolve(['apple', 'banana']) - }, 10) - }) - }) - .argv; + resolve(['apple', 'banana']); + }, 10); + }); + } +).argv; ``` Using default completions in a custom implementation. When invoked with no arguments, `completionFilter` will fallback to the default completion function. There is no need to call `done` in this case. When provided with a callback function, you can get access to `defaultCompletions` and call `done` with your processed version of them. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .completion('completion', function(current, argv, completionFilter, done) { +var argv = require('yargs/yargs')(process.argv.slice(2)).completion( + 'completion', + function (current, argv, completionFilter, done) { // if 'apple' present return default completions if (argv._.includes('apple')) { completionFilter(); } else { completionFilter((err, defaultCompletions) => { const filteredCompletions = defaultCompletions.filter( - completion => !completion.includes('banana'), + completion => !completion.includes('banana') ); // else return default completions w/o 'banana' done(filteredCompletions); }); } - }) - .argv; + } +).argv; ``` -.config([key], [description], [parseFn]) -------------------------------------------------------------- -.config(object) ---------------- +## .config([key], [description], [parseFn]) + +## .config(object) Tells the parser that if the option specified by `key` is passed in, it should be interpreted as a path to a JSON config file. The file is loaded @@ -450,21 +435,23 @@ function must be synchronous, and should return an object containing key value pairs or an error. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .config('settings', function (configPath) { - return JSON.parse(fs.readFileSync(configPath, 'utf-8')) - }) - .argv +var argv = require('yargs/yargs')(process.argv.slice(2)).config( + 'settings', + function (configPath) { + return JSON.parse(fs.readFileSync(configPath, 'utf-8')); + } +).argv; ``` You can also pass an explicit configuration `object`, it will be parsed and its properties will be set as arguments. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .config({foo: 1, bar: 2}) - .argv -console.log(argv) +var argv = require('yargs/yargs')(process.argv.slice(2)).config({ + foo: 1, + bar: 2, +}).argv; +console.log(argv); ``` ``` @@ -486,17 +473,17 @@ configuration file, e.g., ```js yargs.config({ extends: './configs/a.json', - logLevel: 'verbose' -}) + logLevel: 'verbose', +}); ``` Or, a module can be provided (this is useful for creating functionality like - [babel-presets](https://babeljs.io/docs/plugins/)). +[babel-presets](https://babeljs.io/docs/plugins/)). **my-library.js** ```js -yargs.pkgConf('nyc') +yargs.pkgConf('nyc'); ``` **consuming package.json** @@ -511,24 +498,21 @@ yargs.pkgConf('nyc') Where `nyc-babel-config` is a package that exports configuration in its index. -.conflicts(x, y) ----------------------------------------------- +## .conflicts(x, y) Given the key `x` is set, the key `y` must not be set. `y` can either be a single string or an array of argument names that `x` conflicts with. Optionally `.conflicts()` can accept an object specifying multiple conflicting keys. -.count(key) ------------- +## .count(key) Interpret `key` as a boolean flag, but set its parsed value to the number of flag occurrences rather than `true` or `false`. Default value is thus `0`. -.default(key, value, [description]) ---------------------------------------------------------- -.defaults(key, value, [description]) [DEPRECATED] ------------------------------------- +## .default(key, value, [description]) + +## .defaults(key, value, [description]) [DEPRECATED] **Note:** The `.defaults()` alias is deprecated. It will be removed in the next major version. Use `.default()` instead. @@ -541,10 +525,12 @@ But wait, there's more! The default value can be a `function` which returns a value. The name of the function will be used in the usage string: ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .default('random', function randomValue() { +var argv = require('yargs/yargs')(process.argv.slice(2)).default( + 'random', + function randomValue() { return Math.random() * 256; - }).argv; + } +).argv; ``` Optionally, `description` can also be provided and will take precedence over @@ -554,16 +540,14 @@ displaying the value in the usage instructions: .default('timeout', 60000, '(one-minute)') ``` -.demand(count, [max], [msg]) [DEPRECATED] --------------------- +## .demand(count, [max], [msg]) [DEPRECATED] `demand()` has been deprecated, please instead see [`demandOption()`](#demandOption) and [`demandCommand()`](#demandCommand). -.demandOption(key, [msg | boolean]) ------------------------------- -.demandOption(key, msg) ------------------------------- +## .demandOption(key, [msg | boolean]) + +## .demandOption(key, msg) If `key` is a string, show the usage information and exit if `key` wasn't specified in `process.argv`. @@ -577,21 +561,25 @@ If a `msg` string is given, it will be printed when the argument is missing, ins require('yargs/yargs')(process.argv.slice(2)) .option('run', { alias: 'r', - describe: 'run your program' + describe: 'run your program', }) .option('path', { alias: 'p', - describe: 'provide a path to file' + describe: 'provide a path to file', }) .option('spec', { alias: 's', - describe: 'program specifications' + describe: 'program specifications', }) - .demandOption(['run', 'path'], 'Please provide both run and path arguments to work with this tool') - .help() - .argv + .demandOption( + ['run', 'path'], + 'Please provide both run and path arguments to work with this tool' + ) + .help().argv; ``` + which will provide the following output: + ```bash Options: --run, -r run your program [required] @@ -610,25 +598,26 @@ this is useful when using `.options()` to specify command line parameters. // demand individual options within the option constructor require('yargs/yargs')(process.argv.slice(2)) .options({ - 'run': { + run: { alias: 'r', describe: 'run your program', - demandOption: true + demandOption: true, }, - 'path': { + path: { alias: 'p', describe: 'provide a path to file', - demandOption: true + demandOption: true, }, - 'spec': { + spec: { alias: 's', - describe: 'program specifications' - } + describe: 'program specifications', + }, }) - .help() - .argv + .help().argv; ``` + which will provide the following output: + ```bash Options: --run, -r run your program [required] @@ -639,27 +628,26 @@ Options: Missing required arguments: run, path ``` -.demandCommand([min=1], [minMsg]) ------------------------------- -.demandCommand([min=1], [max], [minMsg], [maxMsg]) ------------------------------- +## .demandCommand([min=1], [minMsg]) + +## .demandCommand([min=1], [max], [minMsg], [maxMsg]) Demand in context of commands. You can demand a minimum and a maximum number a user can have within your program, as well as provide corresponding error messages if either of the demands is not met. + ```javascript require('yargs/yargs')(process.argv.slice(2)) .command({ command: 'configure [value]', aliases: ['config', 'cfg'], desc: 'Set a config variable', - builder: (yargs) => yargs.default('value', 'true'), - handler: (argv) => { - console.log(`setting ${argv.key} to ${argv.value}`) - } + builder: yargs => yargs.default('value', 'true'), + handler: argv => { + console.log(`setting ${argv.key} to ${argv.value}`); + }, }) // provide a minimum demand and a minimum demand message .demandCommand(1, 'You need at least one command before moving on') - .help() - .argv + .help().argv; ``` which will provide the following output: @@ -678,8 +666,7 @@ _Note: in `minMsg` and `maxMsg`, every occurrence of `$0` will be replaced with the observed value, and every instance of `$1` will be replaced with the expected value._ -.deprecateOption(key, [msg | boolean]) --------------------- +## .deprecateOption(key, [msg | boolean]) Shows a `[deprecated]` notice in front of the option. @@ -687,8 +674,9 @@ Shows a `[deprecated]` notice in front of the option. require('yargs/yargs')(process.argv.slice(2)) .option('old') .deprecateOption('old') - .option('new') + .option('new'); ``` + ```bash Options: --old [deprecated] @@ -701,8 +689,9 @@ You can also specify a message require('yargs/yargs')(process.argv.slice(2)) .option('old') .deprecateOption('old', 'use --new') - .option('new') + .option('new'); ``` + ```bash Options: --old [deprecated: use --new] @@ -712,35 +701,30 @@ Options: You can also use it within the option constructor ```javascript -require('yargs/yargs')(process.argv.slice(2)) - .option('old', { deprecated: true }) +require('yargs/yargs')(process.argv.slice(2)).option('old', {deprecated: true}); ``` -.describe(key, desc) --------------------- +## .describe(key, desc) Describe a `key` for the generated usage information. Optionally `.describe()` can take an object that maps keys to descriptions. -.hide(key) --------------------- +## .hide(key) Hides a `key` from the generated usage information. Unless a `--show-hidden` option is also passed with `--help` (see [`showHidden()`](#showHidden)). -.detectLocale(boolean) ------------ +## .detectLocale(boolean) Should yargs attempt to detect the os' locale? Defaults to `true`. -.env([prefix]) --------------- +## .env([prefix]) Tell yargs to parse environment variables matching the given prefix and apply them to argv as though they were command line arguments. Use the "\_\_" separator in the environment variable to indicate nested options. -(e.g. prefix_nested__foo => nested.foo) +(e.g. prefix_nested\_\_foo => nested.foo) If this method is called with no argument or with an empty string or with `true`, then all env vars will be applied to argv. @@ -757,10 +741,9 @@ var argv = require('yargs/yargs')(process.argv.slice(2)) .env('MY_PROGRAM') .option('f', { alias: 'fruit-thing', - default: 'apple' - }) - .argv -console.log(argv) + default: 'apple', + }).argv; +console.log(argv); ``` ``` @@ -793,22 +776,21 @@ $ MY_PROGRAM_FRUIT_THING=banana node fruity.js -f cat Env var parsing is disabled by default, but you can also explicitly disable it by calling `.env(false)`, e.g. if you need to undo previous configuration. -.epilog(str) ------------- -.epilogue(str) --------------- +## .epilog(str) + +## .epilogue(str) A message to print at the end of the usage instructions, e.g. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .epilogue('for more information, find our manual at http://example.com'); +var argv = require('yargs/yargs')(process.argv.slice(2)).epilogue( + 'for more information, find our manual at http://example.com' +); ``` -.example(cmd, desc) -------------------- -.example([[cmd1, desc1], [cmd2, desc2], ...]) -------------------- +## .example(cmd, desc) + +## .example([[cmd1, desc1], [cmd2, desc2], ...]) Give some example invocations of your program. Inside `cmd`, the string `$0` will get interpolated to the current script name or node command for the @@ -816,33 +798,31 @@ present script similar to how `$0` works in bash or perl. Examples will be printed out as part of the help message. If you want to add multiple examples at once, just pass an array of examples, e.g + ```js -require('yargs/yargs')(process.argv.slice(2)) - .example([ - ['$0 --config "~/config.json"', 'Use custom config'], - ['$0 --safe', 'Start in safe mode'] - ]); +require('yargs/yargs')(process.argv.slice(2)).example([ + ['$0 --config "~/config.json"', 'Use custom config'], + ['$0 --safe', 'Start in safe mode'], +]); ``` -.exitProcess(enable) ----------------------------------- +## .exitProcess(enable) By default, yargs exits the process when the user passes a help flag, the user uses the `.version` functionality, validation fails, or the command handler fails. Calling `.exitProcess(false)` disables this behavior, enabling further actions after yargs have been validated. -***Note:*** `.exitProcess(false)` should not be used when [`.command()`](#command) +**_Note:_** `.exitProcess(false)` should not be used when [`.command()`](#command) is called with a handler returning a promise, as it would lead to a duplicated error message when this promise rejects -.exit(code, err) ---------- +## .exit(code, err) + Manually indicate that the program should exit, and provide context about why we wanted to exit. Follows the behavior set by `.exitProcess()`. -.fail(fn | boolean) ---------- +## .fail(fn | boolean) Method to execute when a failure occurs, rather than printing the failure message. @@ -855,19 +835,20 @@ handle failures yourself using `try`/`catch` and [`.getHelp()`](#get-help). occurred. ```js -var argv = require('yargs/yargs')(process.argv.slice(2)) - .fail(function (msg, err, yargs) { - if (err) throw err // preserve stack - console.error('You broke it!') - console.error(msg) - console.error('You should be doing', yargs.help()) - process.exit(1) - }) - .argv +var argv = require('yargs/yargs')(process.argv.slice(2)).fail(function ( + msg, + err, + yargs +) { + if (err) throw err; // preserve stack + console.error('You broke it!'); + console.error(msg); + console.error('You should be doing', yargs.help()); + process.exit(1); +}).argv; ``` -.getCompletion(args, done); ---------------------------- +## .getCompletion(args, done); Allows to programmatically get completion choices for any line. @@ -886,20 +867,18 @@ require('yargs/yargs')(process.argv.slice(2)) .option('foobaz') .completion() .getCompletion(['./test.js', '--foo'], function (completions) { - console.log(completions) - }) + console.log(completions); + }); ``` Outputs the same completion choices as `./test.js --foo`TAB: `--foobar` and `--foobaz` -.getHelp() ---------------------------- +## .getHelp() Returns a promise that resolves with a `string` equivalent to what would be output by [`.showHelp()`](#show-help), or by running yargs with `--help`. -.global(globals, [global=true]) ------------- +## .global(globals, [global=true]) Indicate that an option (or group of options) should not be reset when a command is executed, as an example: @@ -909,21 +888,20 @@ var argv = require('yargs/yargs')(process.argv.slice(2)) .option('a', { alias: 'all', default: true, - global: false + global: false, }) .option('n', { alias: 'none', default: true, - global: false + global: false, }) .command('foo', 'foo command', function (yargs) { return yargs.option('b', { - alias: 'bar' - }) + alias: 'bar', + }); }) .help('help') - .global('a') - .argv + .global('a').argv; ``` If the `foo` command is executed the `all` option will remain, but the `none` @@ -931,8 +909,7 @@ option will have been eliminated. Options default to being global. -.group(key(s), groupName) --------------------- +## .group(key(s), groupName) Given a key, or an array of keys, places options under an alternative heading when displaying usage instructions, e.g., @@ -942,22 +919,22 @@ require('yargs/yargs')(['--help']) .help() .group('batman', 'Heroes:') .describe('batman', "world's greatest detective") - .wrap(null) - .argv + .wrap(null).argv; ``` -*** + +--- + Heroes: --batman world's greatest detective Options: --help Show help [boolean] -.help() ------------------------------------------ -.help([option | boolean]) ------------------------------------------ -.help([option, [description]]) ------------------------------------------ +## .help() + +## .help([option | boolean]) + +## .help([option, [description]]) Configure an (e.g. `--help`) and implicit command that displays the usage string and exits the process. By default yargs enables help on the `--help` option. @@ -977,14 +954,12 @@ If invoked without parameters, `.help()` will use `--help` as the option and Example: ```js -var yargs = require("yargs")(['--info']) - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]") - .help('info') - .argv +var yargs = require('yargs')(['--info']) + .usage('$0 -operand1 number -operand2 number -operation [add|subtract]') + .help('info').argv; ``` -.implies(x, y) --------------- +## .implies(x, y) Given the key `x` is set, it is required that the key `y` is set. `y` can either be the name of an argument to imply, a number indicating the @@ -992,8 +967,7 @@ position of an argument or an array of multiple implications to associate with ` Optionally `.implies()` can accept an object specifying multiple implications. -.locale() ---------- +## .locale() Return the locale that yargs is currently using. @@ -1003,8 +977,7 @@ yargs-generated help content will display in the user's language. To override this behavior with a static locale, pass the desired locale as a string to this method (see below). -.locale(locale) ---------------- +## .locale(locale) Override the auto-detected locale from the user's operating system with a static locale. Note that the OS locale can be modified by setting/exporting the `LC_ALL` @@ -1016,17 +989,16 @@ var argv = require('yargs/yargs')(process.argv.slice(2)) .option('option', { alias: 'o', describe: "'tis a mighty fine option", - demandOption: true + demandOption: true, }) .command('run', "Arrr, ya best be knowin' what yer doin'") .example('$0 run foo', "shiver me timbers, here's an example for ye") .help('help') .wrap(70) - .locale('pirate') - .argv + .locale('pirate').argv; ``` -*** +--- ```shell ./test.js - follow ye instructions true @@ -1046,57 +1018,56 @@ Ye be havin' to set the followin' argument land lubber: option Locales currently supported: -* **be:** Belarusian. -* **de:** German. -* **en:** American English. -* **es:** Spanish. -* **fr:** French. -* **hi:** Hindi. -* **hu:** Hungarian. -* **id:** Indonesian. -* **it:** Italian. -* **ja:** Japanese. -* **ko:** Korean. -* **nb:** Norwegian Bokmål. -* **nl:** Dutch. -* **nn:** Norwegian Nynorsk. -* **pirate:** American Pirate. -* **pl:** Polish. -* **pt:** Portuguese. -* **pt_BR:** Brazilian Portuguese. -* **ru:** Russian. -* **uz:** Uzbek. -* **th:** Thai. -* **tr:** Turkish. -* **zh_CN:** Chinese (Mainland China). -* **zh_TW:** Chinese (Taiwan). +- **be:** Belarusian. +- **de:** German. +- **en:** American English. +- **es:** Spanish. +- **fr:** French. +- **hi:** Hindi. +- **hu:** Hungarian. +- **id:** Indonesian. +- **it:** Italian. +- **ja:** Japanese. +- **ko:** Korean. +- **nb:** Norwegian Bokmål. +- **nl:** Dutch. +- **nn:** Norwegian Nynorsk. +- **pirate:** American Pirate. +- **pl:** Polish. +- **pt:** Portuguese. +- **pt_BR:** Brazilian Portuguese. +- **ru:** Russian. +- **uz:** Uzbek. +- **th:** Thai. +- **tr:** Turkish. +- **zh_CN:** Chinese (Mainland China). +- **zh_TW:** Chinese (Taiwan). To submit a new translation for yargs: 1. use `./locales/en.json` as a starting point. 2. submit a pull request with the new locale file. -*The [Microsoft Terminology Search](https://www.microsoft.com/en-us/language/Search) can be useful for finding the correct terminology in your locale.* +_The [Microsoft Terminology Search](https://www.microsoft.com/en-us/language/Search) can be useful for finding the correct terminology in your locale._ -.middleware(callbacks, [applyBeforeValidation]) ------------------------------------- +## .middleware(callbacks, [applyBeforeValidation]) Define global middleware functions to be called first, in list order, for all cli command. -The `callbacks` parameter can be a function or a list of functions. Each callback gets passed a reference to argv. +The `callbacks` parameter can be a function or a list of functions. Each callback gets passed a reference to argv. ```js -const mwFunc1 = argv => console.log('I\'m a middleware function'); -const mwFunc2 = argv => console.log('I\'m another middleware function'); +const mwFunc1 = argv => console.log("I'm a middleware function"); +const mwFunc2 = argv => console.log("I'm another middleware function"); yargs - .command('myCommand', 'some command', {}, function(argv){ + .command('myCommand', 'some command', {}, function (argv) { console.log('Running myCommand!'); }) .middleware([mwFunc1, mwFunc2]).argv; ``` -When calling `myCommand` from the command line, mwFunc1 gets called first, then mwFunc2, and finally the command's handler. The console output is: +When calling `myCommand` from the command line, mwFunc1 gets called first, then mwFunc2, and finally the command's handler. The console output is: ``` I'm a middleware function @@ -1104,7 +1075,7 @@ I'm another middleware function Running myCommand! ``` -Middleware can be applied before validation by setting the second parameter to `true`. This will execute the middleware prior to validation checks, but after parsing. +Middleware can be applied before validation by setting the second parameter to `true`. This will execute the middleware prior to validation checks, but after parsing. Middleware is passed two parameters `argv`, the current parsed options object, and `yargs` the yargs instance itself, which provides contextual information @@ -1117,20 +1088,22 @@ handler function. // populating home directory from an environment variable. require('yargs/yargs')(process.argv.slice(2)) .middleware(function (argv) { - if (process.env.HOME) argv.home = process.env.HOME + if (process.env.HOME) argv.home = process.env.HOME; }, true) - .command('configure-home', "do something with a user's home directory", + .command( + 'configure-home', + "do something with a user's home directory", { - 'home': { - 'demand': true, - 'string': true - } + home: { + demand: true, + string: true, + }, }, - function(argv) { - console.info(`we know the user's home directory is ${argv.home}`) + function (argv) { + console.info(`we know the user's home directory is ${argv.home}`); } ) - .parse() + .parse(); ``` Example, Using middleware to apply a transformation on argv after `choices` have @@ -1138,11 +1111,16 @@ been enforced ([see #756](https://github.com/yargs/yargs/issues/756)): ```js require('yargs') - .command('$0', 'accept username', () => {}, (argv) => { - // The middleware will have been applied before the default - // command is called: - console.info(argv); - }) + .command( + '$0', + 'accept username', + () => {}, + argv => { + // The middleware will have been applied before the default + // command is called: + console.info(argv); + } + ) .choices('user', ['Goofy', 'Miky']) .middleware(argv => { console.info('gots here'); @@ -1166,8 +1144,7 @@ require('yargs') .parse('--user Miky'); ``` -.nargs(key, count) ------------ +## .nargs(key, count) The number of arguments that should be consumed after a key. This can be a useful hint to prevent parsing ambiguity. For example: @@ -1184,13 +1161,11 @@ parses as: Optionally `.nargs()` can take an object of `key`/`narg` pairs. -.normalize(key) ---------------- +## .normalize(key) The key provided represents a path and should have `path.normalize()` applied. -.number(key) ------------- +## .number(key) Tell the parser to always interpret `key` as a number. @@ -1207,14 +1182,12 @@ Note that decimals, hexadecimals, and scientific notation are all accepted. ```js var argv = require('yargs/yargs')(process.argv.slice(2)) .number('n') - .number(['width', 'height']) - .argv + .number(['width', 'height']).argv; ``` -.option(key, [opt]) ------------------ -.options(key, [opt]) ------------------- +## .option(key, [opt]) + +## .options(key, [opt]) This method can be used to make yargs aware of options that _could_ exist. You can also pass an `opt` object which can hold further @@ -1223,46 +1196,38 @@ customization, like `.alias()`, `.demandOption()` etc. for that option. For example: ```javascript -var argv = require('yargs/yargs')(process.argv.slice(2)) - .option('f', { - alias: 'file', - demandOption: true, - default: '/etc/passwd', - describe: 'x marks the spot', - type: 'string' - }) - .argv -; +var argv = require('yargs/yargs')(process.argv.slice(2)).option('f', { + alias: 'file', + demandOption: true, + default: '/etc/passwd', + describe: 'x marks the spot', + type: 'string', +}).argv; ``` is the same as ```javascript var argv = require('yargs/yargs')(process.argv.slice(2)) - .alias('f', 'file') - .demandOption('f') - .default('f', '/etc/passwd') - .describe('f', 'x marks the spot') - .string('f') - .argv -; + .alias('f', 'file') + .demandOption('f') + .default('f', '/etc/passwd') + .describe('f', 'x marks the spot') + .string('f').argv; ``` Optionally `.options()` can take an object that maps keys to `opt` parameters. ```javascript -var argv = require('yargs/yargs')(process.argv.slice(2)) - .options({ - 'f': { - alias: 'file', - demandOption: true, - default: '/etc/passwd', - describe: 'x marks the spot', - type: 'string' - } - }) - .argv -; +var argv = require('yargs/yargs')(process.argv.slice(2)).options({ + f: { + alias: 'file', + demandOption: true, + default: '/etc/passwd', + describe: 'x marks the spot', + type: 'string', + }, +}).argv; ``` Valid `opt` keys include: @@ -1292,14 +1257,13 @@ Valid `opt` keys include: - `skipValidation`: boolean, skips validation if the option is present, see [`skipValidation()`](#skipValidation) - `string`: boolean, interpret option as a string, see [`string()`](#string) - `type`: one of the following strings - - `'array'`: synonymous for `array: true`, see [`array()`](#array) - - `'boolean'`: synonymous for `boolean: true`, see [`boolean()`](#boolean) - - `'count'`: synonymous for `count: true`, see [`count()`](#count) - - `'number'`: synonymous for `number: true`, see [`number()`](#number) - - `'string'`: synonymous for `string: true`, see [`string()`](#string) + - `'array'`: synonymous for `array: true`, see [`array()`](#array) + - `'boolean'`: synonymous for `boolean: true`, see [`boolean()`](#boolean) + - `'count'`: synonymous for `count: true`, see [`count()`](#count) + - `'number'`: synonymous for `number: true`, see [`number()`](#number) + - `'string'`: synonymous for `string: true`, see [`string()`](#string) -.parse([args], [context], [parseCallback]) ------------- +## .parse([args], [context], [parseCallback]) Parse `args` instead of `process.argv`. Returns the `argv` object. `args` may either be a pre-processed argv array, or a raw argument string. @@ -1309,10 +1273,15 @@ useful mechanism for passing state information to commands: ```js const parser = yargs - .command('lunch-train ', 'start lunch train', function () {}, function (argv) { - console.log(argv.restaurant, argv.time) - }) - .parse("lunch-train rudy's", {time: '12:15'}) + .command( + 'lunch-train ', + 'start lunch train', + function () {}, + function (argv) { + console.log(argv.restaurant, argv.time); + } + ) + .parse("lunch-train rudy's", {time: '12:15'}); ``` A `parseCallback` can also be provided to `.parse()`. If a callback is given, it will be invoked with three arguments: @@ -1320,83 +1289,87 @@ A `parseCallback` can also be provided to `.parse()`. If a callback is given, it 1. `err`: populated if any validation errors raised while parsing. 2. `argv`: the parsed argv object. 3. `output`: any text that would have been output by yargs to the terminal, had a - callback not been provided. + callback not been provided. ```js // providing the `fn` argument to `parse()` runs yargs in headless mode, this // makes it easy to use yargs in contexts other than the CLI, e.g., writing // a chat-bot. const parser = yargs - .command('lunch-train