add cli.ts
This commit is contained in:
parent
a6e7906e20
commit
54fd85694d
2 changed files with 23 additions and 14 deletions
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;
|
||||
}
|
||||
|
||||
const privateKey = await readPrivateKey();
|
||||
const siteTag = await askInput("site tag:");
|
||||
let password = await askInput("password:", true);
|
||||
if (password.slice(password.length - 1) != "#") {
|
||||
password += "#";
|
||||
}
|
||||
export async function showZenityUI(): Promise<void> {
|
||||
const privateKey = await readPrivateKey();
|
||||
const siteTag = await askInput("site tag:");
|
||||
let password = await askInput("password:", true);
|
||||
if (password.slice(password.length - 1) != "#") {
|
||||
password += "#";
|
||||
}
|
||||
|
||||
const hasher = new Hasher(privateKey);
|
||||
hasher.site_tag = siteTag;
|
||||
const result = hasher.tryHashing(password);
|
||||
if (result) {
|
||||
await copyToClipboard(result);
|
||||
await showMessage(`Your hashed password (copied to clipboard): ${result}`);
|
||||
} else {
|
||||
await showMessage(`Error in hashing password`);
|
||||
const hasher = new Hasher(privateKey);
|
||||
hasher.site_tag = siteTag;
|
||||
const result = hasher.tryHashing(password);
|
||||
if (result) {
|
||||
await copyToClipboard(result);
|
||||
await showMessage(`Your hashed password (copied to clipboard): ${result}`);
|
||||
} else {
|
||||
await showMessage(`Error in hashing password`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue