1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

[PM-3326] [CLI] Add minNumber, minSpecial and ambiguous password generation options (#5974)

* feat(cli): add minNumber option and pass to generation service

* feat(cli): add minSpecial option and pass to generation service

* feat(cli): add ambiguous option and pass to generation service

* refactor: extract utils to convert number and string options

* feat(ts): add types to utils and options

* feat: validate result of parsed value in convertNumberOption util
This commit is contained in:
José Pereira
2023-09-04 21:01:16 +01:00
committed by GitHub
parent bf7aa6473e
commit a920d62dfe
3 changed files with 33 additions and 4 deletions

View File

@@ -253,4 +253,20 @@ export class CliUtils {
static convertBooleanOption(optionValue: any) {
return optionValue || optionValue === "" ? true : false;
}
static convertNumberOption(optionValue: any, defaultValue: number) {
try {
if (optionValue != null) {
const numVal = parseInt(optionValue);
return !Number.isNaN(numVal) ? numVal : defaultValue;
}
return defaultValue;
} catch {
return defaultValue;
}
}
static convertStringOption(optionValue: any, defaultValue: string) {
return optionValue != null ? String(optionValue) : defaultValue;
}
}