-
Notifications
You must be signed in to change notification settings - Fork 5
Open
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:
const foo = command({
name: 'foo',
options: {
foo: string().default(() => process.env.FOO, 'process.env.FOO'),
bar: number().default(() => 2 ** 32),
}
})roll
Metadata
Metadata
Assignees
Labels
No labels