yargs 3.21.1 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +9 -2
- package/index.js +20 -8
- package/lib/locale.js +19 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### v3.23.0 (2015/08/30 23:00 +00:00)
|
|
4
|
+
|
|
5
|
+
- [#246](https://github.com/bcoe/yargs/pull/246) detect locale based only on environment variables (@bcoe)
|
|
6
|
+
- [#244](https://github.com/bcoe/yargs/pull/244) adds Windows CI testing (@bcoe)
|
|
7
|
+
- [#245](https://github.com/bcoe/yargs/pull/245) adds OSX CI testing (@bcoe, @nexdrew)
|
|
8
|
+
|
|
9
|
+
### v3.22.0 (2015/08/28 22:26 +00:00)
|
|
10
|
+
- [#242](https://github.com/bcoe/yargs/pull/242) adds detectLocale config option (@bcoe)
|
|
11
|
+
|
|
3
12
|
### v3.21.1 (2015/08/28 20:58 +00:00)
|
|
4
13
|
- [#240](https://github.com/bcoe/yargs/pull/240) hot-fix for Atom on Windows (@bcoe)
|
|
5
14
|
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ With yargs, ye be havin' a map that leads straight to yer treasure! Treasure of
|
|
|
9
9
|
[![Dependency Status][gemnasium-image]][gemnasium-url]
|
|
10
10
|
[![Coverage Status][coveralls-image]][coveralls-url]
|
|
11
11
|
[![NPM version][npm-image]][npm-url]
|
|
12
|
+
[![Windows Tests][windows-image]][windows-url]
|
|
12
13
|
|
|
13
14
|
> Yargs is the official successor to optimist. Please feel free to submit issues and pull requests. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/bcoe/yargs/issues) :)
|
|
14
15
|
|
|
@@ -655,8 +656,7 @@ Optionally `.implies()` can accept an object specifying multiple implications.
|
|
|
655
656
|
|
|
656
657
|
Return the locale that yargs is currently using.
|
|
657
658
|
|
|
658
|
-
By default, yargs will auto-detect the operating system's locale
|
|
659
|
-
(via [os-locale](https://www.npmjs.com/package/os-locale)) so that
|
|
659
|
+
By default, yargs will auto-detect the operating system's locale so that
|
|
660
660
|
yargs-generated help content will display in the user's language.
|
|
661
661
|
|
|
662
662
|
To override this behavior with a static locale, pass the desired locale as a
|
|
@@ -717,6 +717,11 @@ To submit a new translation for yargs:
|
|
|
717
717
|
1. use `./locales/en.json` as a starting point.
|
|
718
718
|
2. submit a pull request with the new locale file.
|
|
719
719
|
|
|
720
|
+
.detectLocale(boolean)
|
|
721
|
+
-----------
|
|
722
|
+
|
|
723
|
+
Should yargs attempt to detect the os' locale? defaults to `true`.
|
|
724
|
+
|
|
720
725
|
.nargs(key, count)
|
|
721
726
|
-----------
|
|
722
727
|
|
|
@@ -1084,3 +1089,5 @@ This module is loosely inspired by Perl's
|
|
|
1084
1089
|
[coveralls-image]: https://img.shields.io/coveralls/bcoe/yargs.svg
|
|
1085
1090
|
[npm-url]: https://npmjs.org/package/yargs
|
|
1086
1091
|
[npm-image]: https://img.shields.io/npm/v/yargs.svg
|
|
1092
|
+
[windows-url]: https://ci.appveyor.com/project/bcoe/yargs
|
|
1093
|
+
[windows-image]: https://img.shields.io/appveyor/ci/bcoe/yargs/master.svg?label=Windows%20Tests
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var assert = require('assert')
|
|
2
2
|
var Completion = require('./lib/completion')
|
|
3
|
-
var
|
|
3
|
+
var locale = require('./lib/locale')
|
|
4
4
|
var Parser = require('./lib/parser')
|
|
5
5
|
var path = require('path')
|
|
6
6
|
var Usage = require('./lib/usage')
|
|
@@ -19,7 +19,6 @@ function Argv (processArgs, cwd) {
|
|
|
19
19
|
var validation = null
|
|
20
20
|
var y18n = Y18n({
|
|
21
21
|
directory: path.resolve(__dirname, './locales'),
|
|
22
|
-
locale: guessLocale(),
|
|
23
22
|
updateFiles: false
|
|
24
23
|
})
|
|
25
24
|
|
|
@@ -408,16 +407,30 @@ function Argv (processArgs, cwd) {
|
|
|
408
407
|
}
|
|
409
408
|
|
|
410
409
|
self.locale = function (locale) {
|
|
411
|
-
if (arguments.length === 0)
|
|
410
|
+
if (arguments.length === 0) {
|
|
411
|
+
guessLocale()
|
|
412
|
+
return y18n.getLocale()
|
|
413
|
+
}
|
|
414
|
+
detectLocale = false
|
|
412
415
|
y18n.setLocale(locale)
|
|
413
416
|
return self
|
|
414
417
|
}
|
|
415
418
|
|
|
416
419
|
self.updateStrings = self.updateLocale = function (obj) {
|
|
420
|
+
detectLocale = false
|
|
417
421
|
y18n.updateLocale(obj)
|
|
418
422
|
return self
|
|
419
423
|
}
|
|
420
424
|
|
|
425
|
+
var detectLocale = true
|
|
426
|
+
self.detectLocale = function (detect) {
|
|
427
|
+
detectLocale = detect
|
|
428
|
+
return self
|
|
429
|
+
}
|
|
430
|
+
self.getDetectLocale = function () {
|
|
431
|
+
return detectLocale
|
|
432
|
+
}
|
|
433
|
+
|
|
421
434
|
self.getUsageInstance = function () {
|
|
422
435
|
return usage
|
|
423
436
|
}
|
|
@@ -454,6 +467,8 @@ function Argv (processArgs, cwd) {
|
|
|
454
467
|
|
|
455
468
|
self.parsed = parsed
|
|
456
469
|
|
|
470
|
+
guessLocale() // guess locale lazily, so that it can be turned off in chain.
|
|
471
|
+
|
|
457
472
|
// while building up the argv object, there
|
|
458
473
|
// are two passes through the parser. If completion
|
|
459
474
|
// is being performed short-circuit on the first pass.
|
|
@@ -532,11 +547,8 @@ function Argv (processArgs, cwd) {
|
|
|
532
547
|
}
|
|
533
548
|
|
|
534
549
|
function guessLocale () {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
} catch (err) {
|
|
538
|
-
return 'en'
|
|
539
|
-
}
|
|
550
|
+
if (!detectLocale) return
|
|
551
|
+
self.locale(locale())
|
|
540
552
|
}
|
|
541
553
|
|
|
542
554
|
function setPlaceholderKeys (argv) {
|
package/lib/locale.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// port of https://github.com/sindresorhus/os-locale
|
|
2
|
+
// that only looks at environment variables.
|
|
3
|
+
module.exports = function () {
|
|
4
|
+
return getEnvLocale()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function getEnvLocale () {
|
|
8
|
+
var env = process.env
|
|
9
|
+
var ret = env.LC_ALL || env.LANGUAGE || env.LANG || env.LC_MESSAGES
|
|
10
|
+
return getLocale(ret)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getLocale (str) {
|
|
14
|
+
return (str && str.replace(/[.:].*/, '')) || fallback()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function fallback () {
|
|
18
|
+
return 'en_US'
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"description": "Light-weight option parsing with an argv hash. No optstrings attached.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"camelcase": "^1.2.1",
|
|
15
15
|
"cliui": "^2.1.0",
|
|
16
16
|
"decamelize": "^1.0.0",
|
|
17
|
-
"os-locale": "^1.2.1",
|
|
18
17
|
"window-size": "^0.1.2",
|
|
19
18
|
"y18n": "^3.1.0"
|
|
20
19
|
},
|
|
@@ -22,12 +21,13 @@
|
|
|
22
21
|
"chai": "^3.2.0",
|
|
23
22
|
"coveralls": "^2.11.4",
|
|
24
23
|
"hashish": "0.0.4",
|
|
25
|
-
"mocha": "^2.
|
|
24
|
+
"mocha": "^2.3.0",
|
|
26
25
|
"nyc": "^3.1.0",
|
|
27
|
-
"standard": "^5.1.
|
|
26
|
+
"standard": "^5.1.1"
|
|
28
27
|
},
|
|
29
28
|
"scripts": {
|
|
30
|
-
"test": "standard && nyc mocha --check-leaks",
|
|
29
|
+
"test": "standard && nyc mocha --timeout=4000 --check-leaks",
|
|
30
|
+
"test-windows": "mocha --timeout=4000",
|
|
31
31
|
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|