Skip to content

Commit

Permalink
fix(usage): translate 'options' group only when displaying help
Browse files Browse the repository at this point in the history
To allow modifying its translation with updateLocale/updateStrings.

Fixes #1598
  • Loading branch information
Mael LE GUEN committed Mar 25, 2020
1 parent aad7faf commit b519204
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/usage.js
Expand Up @@ -146,7 +146,6 @@ module.exports = function usage (yargs, y18n) {
const deferY18nLookupPrefix = '__yargsString__:'
self.deferY18nLookup = str => deferY18nLookupPrefix + str

const defaultGroup = __('Options:')
self.help = function help () {
if (cachedHelpMessage) return cachedHelpMessage
normalizeAliases()
Expand Down Expand Up @@ -245,8 +244,9 @@ module.exports = function usage (yargs, y18n) {

// populate 'Options:' group with any keys that have not
// explicitly had a group set.
const defaultGroup = __('Options:')
if (!groups[defaultGroup]) groups[defaultGroup] = []
addUngroupedKeys(keys, options.alias, groups)
addUngroupedKeys(keys, options.alias, groups, defaultGroup)

// display 'Options:' table along with any custom tables:
Object.keys(groups).forEach((groupName) => {
Expand Down Expand Up @@ -433,7 +433,7 @@ module.exports = function usage (yargs, y18n) {

// given a set of keys, place any keys that are
// ungrouped under the 'Options:' grouping.
function addUngroupedKeys (keys, aliases, groups) {
function addUngroupedKeys (keys, aliases, groups, defaultGroup) {
let groupedKeys = []
let toCheck = null
Object.keys(groups).forEach((group) => {
Expand Down

0 comments on commit b519204

Please sign in to comment.