-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Español:
Descripción del Problema:
Al usar commander.js, la opción booleana --json no se restablece correctamente cuando se analiza varias veces. En el siguiente ejemplo, la opción --json se mantiene en true después de que se establece, incluso cuando no se pasa en la siguiente llamada a parse. Esto causa un comportamiento inesperado, ya que la opción debería restablecerse a false si no se incluye en la entrada.
Código de ejemplo:
const { Command, createCommand } = require('commander');
const program = createCommand();
const tmp = program
.option('--json', 'output extra debugging', false)
.action(options => console.log(options));
const r1 = program.parse(["node", "app.js"]);
const r2 = program.parse(["node", "app.js", "--json"]);
const r3 = program.parse(["node", "app.js"]);Salida esperada:
{ json: false }
{ json: true }
{ json: false }Salida actual:
{ json: false }
{ json: true }
{ json: true }Comportamiento esperado:
La opción --json debería ser false en la última llamada a parse, pero se mantiene en true, lo que indica que no se restablece correctamente entre llamadas.
Inglés:
Problem Description:
When using commander.js, the boolean option --json does not reset correctly when parsing multiple times. In the following example, the --json option remains true after it is set, even when it is not passed in the subsequent parse call. This leads to unexpected behavior, as the option should reset to false if not included in the input.
Example Code:
const { Command, createCommand } = require('commander');
const program = createCommand();
const tmp = program
.option('--json', 'output extra debugging', false)
.action(options => console.log(options));
const r1 = program.parse(["node", "app.js"]);
const r2 = program.parse(["node", "app.js", "--json"]);
const r3 = program.parse(["node", "app.js"]);Expected Output:
{ json: false }
{ json: true }
{ json: false }Actual Output:
{ json: false }
{ json: true }
{ json: true }Expected Behavior:
The --json option should be false in the final parse call, but it remains true, indicating that it is not resetting properly between calls.
