add cli.ts
This commit is contained in:
parent
a6e7906e20
commit
54fd85694d
7
cli.ts
Executable file
7
cli.ts
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env -S deno run --allow-run --allow-read
|
||||||
|
import { showZenityUI } from "./ui/zenity.ts";
|
||||||
|
|
||||||
|
if (import.meta.main) {
|
||||||
|
// TODO fall back on terminal UI if zenity is not available
|
||||||
|
await showZenityUI();
|
||||||
|
}
|
30
ui/zenity.ts
30
ui/zenity.ts
|
@ -37,19 +37,21 @@ async function readPrivateKey(): Promise<string> {
|
||||||
return config.privateKey;
|
return config.privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
const privateKey = await readPrivateKey();
|
export async function showZenityUI(): Promise<void> {
|
||||||
const siteTag = await askInput("site tag:");
|
const privateKey = await readPrivateKey();
|
||||||
let password = await askInput("password:", true);
|
const siteTag = await askInput("site tag:");
|
||||||
if (password.slice(password.length - 1) != "#") {
|
let password = await askInput("password:", true);
|
||||||
password += "#";
|
if (password.slice(password.length - 1) != "#") {
|
||||||
}
|
password += "#";
|
||||||
|
}
|
||||||
|
|
||||||
const hasher = new Hasher(privateKey);
|
const hasher = new Hasher(privateKey);
|
||||||
hasher.site_tag = siteTag;
|
hasher.site_tag = siteTag;
|
||||||
const result = hasher.tryHashing(password);
|
const result = hasher.tryHashing(password);
|
||||||
if (result) {
|
if (result) {
|
||||||
await copyToClipboard(result);
|
await copyToClipboard(result);
|
||||||
await showMessage(`Your hashed password (copied to clipboard): ${result}`);
|
await showMessage(`Your hashed password (copied to clipboard): ${result}`);
|
||||||
} else {
|
} else {
|
||||||
await showMessage(`Error in hashing password`);
|
await showMessage(`Error in hashing password`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue