Archived
1
0

feat(testing): add test for optionDescriptions (#4970)

* feat(testing): add test for optionDescriptions

* refactor(cli): optional arg in optionDescriptions

* feat: add more tests for optionDescriptions
This commit is contained in:
Joe Previte
2022-03-11 13:27:19 -07:00
committed by GitHub
parent 77296c7187
commit 91cabbc246
2 changed files with 103 additions and 4 deletions

View File

@ -120,11 +120,11 @@ type OptionType<T> = T extends boolean
? "string[]"
: "unknown"
type Options<T> = {
export type Options<T> = {
[P in keyof T]: Option<OptionType<T[P]>>
}
const options: Options<Required<UserProvidedArgs>> = {
export const options: Options<Required<UserProvidedArgs>> = {
auth: { type: AuthType, description: "The type of authentication to use." },
password: {
type: "string",
@ -235,8 +235,8 @@ const options: Options<Required<UserProvidedArgs>> = {
},
}
export const optionDescriptions = (): string[] => {
const entries = Object.entries(options).filter(([, v]) => !!v.description)
export const optionDescriptions = (opts: Partial<Options<Required<UserProvidedArgs>>> = options): string[] => {
const entries = Object.entries(opts).filter(([, v]) => !!v.description)
const widths = entries.reduce(
(prev, [k, v]) => ({
long: k.length > prev.long ? k.length : prev.long,