diff --git a/flags/bool_test.ts b/flags/bool_test.ts index a33e9be0b1c3..422ae0933503 100755 --- a/flags/bool_test.ts +++ b/flags/bool_test.ts @@ -155,3 +155,14 @@ test(function booleanParsingFalse(): void { assertEquals(parsed.boool, false); }); + +test(function booleanParsingTrueLike(): void { + const parsed = parse(["-t", "true123"], { boolean: ["t"] }); + assertEquals(parsed.t, true); + + const parsed2 = parse(["-t", "123"], { boolean: ["t"] }); + assertEquals(parsed2.t, true); + + const parsed3 = parse(["-t", "false123"], { boolean: ["t"] }); + assertEquals(parsed3.t, true); +}); diff --git a/flags/mod.ts b/flags/mod.ts index 0ebaaf52eb15..61cd06f911ad 100644 --- a/flags/mod.ts +++ b/flags/mod.ts @@ -271,7 +271,7 @@ export function parse( ) { setArg(key, args[i + 1], arg); i++; - } else if (args[i + 1] && /true|false/.test(args[i + 1])) { + } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) { setArg(key, args[i + 1] === "true", arg); i++; } else {