Created
September 19, 2023 20:01
-
-
Save abernier/c30a75b7c7100133e2f1f098c8b53a4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "@johnlindquist/kit"; | |
import { generateMultiple, GenerateOptions } from "generate-password"; | |
import rc from "rc"; | |
const defaultConfig = {}; | |
const config: GenerateOptions = rc("generate-password", defaultConfig); | |
const flags = { | |
copy: { | |
name: "copy", | |
shortcut: "cmd+c", | |
}, | |
}; | |
const chosenPass = await arg( | |
{ | |
description: `Length`, | |
flags, | |
}, | |
(input) => { | |
const options = { ...config }; | |
const length = (input && Number(input)) || undefined; | |
if (length) options.length = length; | |
const newPasses = generateMultiple(10, options); | |
return newPasses.map((newPass) => ({ | |
name: newPass, | |
// preview: () => { | |
// return md(`\`${newPass}\``); | |
// }, | |
value: newPass, | |
})); | |
} | |
); | |
if (flag?.copy) { | |
copy(chosenPass); | |
} else { | |
setSelectedText(chosenPass); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment