From 505e8063cf90bfe4a58080e2965b8cff87ba0399 Mon Sep 17 00:00:00 2001 From: Jan Dockx Date: Sun, 10 Mar 2019 22:09:25 +0100 Subject: [PATCH 1/6] Change the label for "Implications failed:" in English The word "implications" is extremely confusing here. It is only people who know the Yargs API that understand that these are the dependencies created by the `implies()` method. Users of the CLI have no idea what we are talking about. This changes the label of the concept to "required argument dependencies". This string is used in the code as the prelude to a list of "implications" that have failed, not a warning. The earlier form was more an expression of a warning. The new form is more an expression of a title of a list. --- locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index fc65c2a0d..33e7b1912 100644 --- a/locales/en.json +++ b/locales/en.json @@ -29,7 +29,7 @@ "Invalid values:": "Invalid values:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Given: %s, Choices: %s", "Argument check failed: %s": "Argument check failed: %s", - "Implications failed:": "Implications failed:", + "Implications failed:": "Missing required argument dependencies:", "Not enough arguments following: %s": "Not enough arguments following: %s", "Invalid JSON config file: %s": "Invalid JSON config file: %s", "Path to JSON config file": "Path to JSON config file", From abde1233c6dd010d7167ec0f480fc30999c3cac3 Mon Sep 17 00:00:00 2001 From: Jan Dockx Date: Tue, 7 May 2019 09:21:16 +0200 Subject: [PATCH 2/6] Change the label for "Implications failed:" to "Missing dependent arguments:", as discussed in PR --- locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index 33e7b1912..b32a63f27 100644 --- a/locales/en.json +++ b/locales/en.json @@ -29,7 +29,7 @@ "Invalid values:": "Invalid values:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Given: %s, Choices: %s", "Argument check failed: %s": "Argument check failed: %s", - "Implications failed:": "Missing required argument dependencies:", + "Implications failed:": "Missing dependent arguments:", "Not enough arguments following: %s": "Not enough arguments following: %s", "Invalid JSON config file: %s": "Invalid JSON config file: %s", "Path to JSON config file": "Path to JSON config file", From b6a7174535b087c6c065efe69ebf54b740d882ef Mon Sep 17 00:00:00 2001 From: Jan Dockx Date: Tue, 7 May 2019 09:22:43 +0200 Subject: [PATCH 3/6] Change the Dutch label for "Implications failed:" to a phrase like "Missing dependent arguments:" in English --- locales/nl.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/nl.json b/locales/nl.json index a27665255..5d62e0fc3 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -29,7 +29,7 @@ "Invalid values:": "Ongeldige waarden:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeven: %s, Keuzes: %s", "Argument check failed: %s": "Argumentcontrole mislukt: %s", - "Implications failed:": "Mislukte implicaties:", + "Implications failed:": "Ontbrekende afhankelijke argumenten:", "Not enough arguments following: %s": "Niet genoeg argumenten na: %s", "Invalid JSON config file: %s": "Ongeldig JSON-config-bestand: %s", "Path to JSON config file": "Pad naar JSON-config-bestand", From f0240dac347673fdaf459ee5cb43dcd670c183d6 Mon Sep 17 00:00:00 2001 From: Jan Dockx Date: Tue, 7 May 2019 09:26:09 +0200 Subject: [PATCH 4/6] Change the French, German and Italian label for "Implications failed:" to a phrase like "Missing dependent arguments:" in English --- locales/de.json | 2 +- locales/fr.json | 2 +- locales/it.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/de.json b/locales/de.json index d805710b0..05d983737 100644 --- a/locales/de.json +++ b/locales/de.json @@ -29,7 +29,7 @@ "Invalid values:": "Unzulässige Werte:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeben: %s, Möglichkeiten: %s", "Argument check failed: %s": "Argumente-Check fehlgeschlagen: %s", - "Implications failed:": "Implikationen fehlgeschlagen:", + "Implications failed:": "Fehlende abhängige Argumente:", "Not enough arguments following: %s": "Nicht genügend Argumente nach: %s", "Invalid JSON config file: %s": "Fehlerhafte JSON-Config Datei: %s", "Path to JSON config file": "Pfad zur JSON-Config Datei", diff --git a/locales/fr.json b/locales/fr.json index 481f47e37..cf9c74bf5 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -28,7 +28,7 @@ "Invalid values:": "Valeurs invalides:", "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Donné: %s, Choix: %s", "Argument check failed: %s": "Echec de la vérification de l'argument: %s", - "Implications failed:": "Implications échouées:", + "Implications failed:": "Arguments dépendants manquants:", "Not enough arguments following: %s": "Pas assez d'arguments suivant: %s", "Invalid JSON config file: %s": "Fichier de configuration JSON invalide: %s", "Path to JSON config file": "Chemin du fichier de configuration JSON", diff --git a/locales/it.json b/locales/it.json index f9eb3756e..9ee900d34 100644 --- a/locales/it.json +++ b/locales/it.json @@ -29,7 +29,7 @@ "Invalid values:": "Valori non validi:", "Argument: %s, Given: %s, Choices: %s": "Argomento: %s, Richiesto: %s, Scelte: %s", "Argument check failed: %s": "Controllo dell'argomento fallito: %s", - "Implications failed:": "Argomenti impliciti non soddisfatti:", + "Implications failed:": "Argomenti dipendenti mancanti:", "Not enough arguments following: %s": "Argomenti insufficienti dopo: %s", "Invalid JSON config file: %s": "File di configurazione JSON non valido: %s", "Path to JSON config file": "Percorso del file di configurazione JSON", From ad22e4dd823533ec413788458d417574e997bf25 Mon Sep 17 00:00:00 2001 From: Jan Dockx Date: Tue, 7 May 2019 09:33:53 +0200 Subject: [PATCH 5/6] fix test for validation / implies automatically use the expected English validation message --- test/validation.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/validation.js b/test/validation.js index ecf98ebd6..60d23441d 100644 --- a/test/validation.js +++ b/test/validation.js @@ -3,6 +3,7 @@ const checkUsage = require('./helpers/utils').checkOutput const expect = require('chai').expect +const english = require('../locales/en.json') let yargs = require('../') require('chai').should() @@ -13,13 +14,15 @@ describe('validation tests', () => { }) describe('implies', () => { + const implicationsFailedPattern = new RegExp(english['Implications failed:']) + it("fails if '_' populated, and implied argument not set", (done) => { yargs(['cat']) .implies({ 1: 'foo' // 1 arg in _ means --foo is required }) .fail((msg) => { - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) return done() }) .parse() @@ -32,7 +35,7 @@ describe('validation tests', () => { 'foo': 1 // --foo means 1 arg in _ is required }) .fail((msg) => { - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) return done() }) .parse() @@ -62,7 +65,7 @@ describe('validation tests', () => { '--no-bar': 'foo' // when --bar is not given, --foo is required }) .fail((msg) => { - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) return done() }) .parse() @@ -74,7 +77,7 @@ describe('validation tests', () => { 'bar': '--no-foo' // --bar means --foo cannot be given }) .fail((msg) => { - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) return done() }) .parse() @@ -89,7 +92,7 @@ describe('validation tests', () => { }) .fail((msg) => { failCalled = true - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) }) .parse() failCalled.should.equal(true) @@ -121,7 +124,7 @@ describe('validation tests', () => { }) .fail((msg) => { failCalled = true - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) }) .parse() failCalled.should.equal(true) @@ -150,7 +153,7 @@ describe('validation tests', () => { implies: 'foo' }) .fail((msg) => { - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) return done() }) .parse() From a803f06a5200b6ad55fa04cc65bce48eb07feb5a Mon Sep 17 00:00:00 2001 From: Jan Dockx Date: Tue, 7 May 2019 09:47:53 +0200 Subject: [PATCH 6/6] fix test/yargs too automatically use the expected English validation message --- test/yargs.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/yargs.js b/test/yargs.js index 40606b7db..47911c1e5 100644 --- a/test/yargs.js +++ b/test/yargs.js @@ -5,12 +5,14 @@ const expect = require('chai').expect const fs = require('fs') const path = require('path') const checkOutput = require('./helpers/utils').checkOutput +const english = require('../locales/en.json') let yargs const YError = require('../lib/yerror') require('chai').should() const noop = () => {} +const implicationsFailedPattern = new RegExp(english['Implications failed:']) describe('yargs dsl tests', () => { beforeEach(() => { @@ -56,7 +58,7 @@ describe('yargs dsl tests', () => { .parse() ) - r.errors[2].should.match(/Implications failed/) + r.errors[2].should.match(implicationsFailedPattern) }) it('accepts an object for describes', () => { @@ -79,7 +81,7 @@ describe('yargs dsl tests', () => { x: 'y' }) .fail((msg) => { - msg.should.match(/Implications failed/) + msg.should.match(implicationsFailedPattern) return done() }) .parse()