Coalesce boolean arguments to actual Boolean type instead of string#763
Coalesce boolean arguments to actual Boolean type instead of string#763joshuayoes wants to merge 5 commits intomasterfrom
Conversation
|
I've added failing tests to demonstrate desired behavior, you can see a sample of those failed test runs here |
|
Only problem I see is that this would definitely be a breaking change in my eyes |
|
It also may be better to take a PR like this, where we could provide the |
|
Got some input from Jamon. Gluegun already doesn't have great type-safety guarantees on command parsing, so this quality of life improvement would be worth a potentially breaking change |
|
I think something changed about ts-node or typescript dependency between now and May. I don't think these changes are causing this issue, but I will investigate more before merging |
jamonholmgren
left a comment
There was a problem hiding this comment.
Good to go (after CI fixed)
I'll merge & release once CI is fixed and you slim down that helper function.
| import { GluegunParameters } from '../domain/toolbox' | ||
| import { Options } from '../domain/options' | ||
| import { equals, is } from './utils' | ||
| import type yargsParser from 'yargs-parser' |
There was a problem hiding this comment.
Smart to use an import type here.
| Object.entries(parsed).map(([key, value]) => { | ||
| // if value is 'true' or 'false', convert to boolean | ||
| if (value === 'true') { | ||
| return [key, true] | ||
| } | ||
| if (value === 'false') { | ||
| return [key, false] | ||
| } | ||
| return [key, value] | ||
| }), |
There was a problem hiding this comment.
I'd use the simplified version here that I mentioned in the related Ignite PR.
|
Merged into #783 since this will be a breaking change too. |

When we pass
--key=falseflag arguments to gluegun, we get{ options: { key: 'false' } }instead of{ options: { key: 'false' } }.This isn't how I expect to consume these in commands. This can handled on the program level, but I feel like that it should be handled on the gluegun level since I can't imagine a use case where we'd want true or false to be a string