Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #165
This supersedes the withdrawn #178, which was closed by its author on Oct 23 with no review or comments. It fixes the same
type: [String]case with the same approach (keep the raw value, no numeric coercion).An option declared with
type: [String]lost leading zeros:-c 01234came back as1234.Root cause: cac's forked
mriparser coerces every numeric-looking value with+valbefore cac's owntypetransform runs, so by the timeString(...)is applied the original text is already gone —String(1234)is"1234", not"01234". The shell strips the quotes, so cac cannot tell a quoted value from an unquoted one; the declared type is the only signal it has.This change:
string: string[]list toMriOptions(src/mri.ts).toValkeeps the raw text for keys in that list instead of coercing them to numbers (aliases included).getMriOptions(src/utils.ts) populates the list from every option whoseconfig.type?.[0] === String, for all of the option's names.type: [String]keep the existing numeric coercion, so-c 1234on an untyped option still yields1234.Tests: Added
String-typed option keeps leading zerosintests/index.test.ts:cli.parse('node bin -c 01234')withtype: [String]now yieldsoptions.chars === ['01234']andoptions.c === '01234'. It failed before the fix (['1234']). Full suite:pnpm vitest run— 23 passed, 0 failed.pnpm typecheckandpnpm lintare clean.Notes for the maintainer:
options.c === '01234'), while the canonical name is array-wrapped by the existingsetByTypebehaviour (options.chars === ['01234']). That matches how aliases already behave for other typed options; I did not change it.type: [String]there is no way for cac to know the value should stay a string, and numeric coercion is the documented default.