drizzle-team / drizzle-team/brocli
feature request: dynamic defaults
- Dominant language
- TypeScript
- Stars
- 477
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
in some cases a default value for an argument might be from an env. variable (or otherwise computed), in which case using a `.default(process.env.FOO)` would a) result in bad ux for the user in `--help` (they wouldn't know where the value comes from), and b) might be expensive
currently the workaround is to keep the argument as optional, put the default value description in the `.desc()` and use `??` in handler/transform function, which adds a bit of boilerplate
i propose an overload for the `.default()` method that would accept a function and optionally a textual description of what happens there:
```ts
const foo = command({
name: 'foo',
options: {
foo: string().default(() => process.env.FOO, 'process.env.FOO'),
bar: number().default(() => 2 ** 32),
}
})
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.