Skip to content

Instantly share code, notes, and snippets.

@abernier
Created September 19, 2023 20:01
Show Gist options
  • Save abernier/c30a75b7c7100133e2f1f098c8b53a4c to your computer and use it in GitHub Desktop.
Save abernier/c30a75b7c7100133e2f1f098c8b53a4c to your computer and use it in GitHub Desktop.
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