Skip to content

Commit

Permalink
👌 IMPROVE: Final format
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Jul 14, 2020
1 parent 09deaf9 commit 02c7e68
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions index.js
Expand Up @@ -7,29 +7,26 @@ const cli = require('./utils/cli.js');
const init = require('./utils/init.js');
const clipboardy = require('clipboardy');
const wifiPassword = require('wifi-password');
const {yellow: y, green: g, dim: d} = require('chalk');
const {yellow: y, green: g, red: r, dim: d} = require('chalk');

const [ssid] = cli.input;
const input = cli.input;
const flags = cli.flags;
const {clear} = flags;
let pass = false;

const failed = () =>
alert({
type: `fail`,
msg: `Password retrieval failed`
});

(async () => {
init({clear});
spinner.start(`${y`PASSWORD`} searching…`);
input.includes('help') && cli.showHelp(0);

spinner.start(`${y`PASSWORD`} searching…\n`);

// Get the password.
try {
pass = await wifiPassword(ssid);
pass = await wifiPassword(input[0]);
spinner.stop();
} catch (error) {
spinner.clear();
failed();
spinner.warn(`${r`PASSWORD`} search cancelled\n`);
console.log(error.message);
console.log();
}

if (pass) {
Expand All @@ -42,9 +39,6 @@ const failed = () =>
msg: pass
});

console.log(d`Password copied to clipboard.\n`);
} else {
spinner.stop();
failed();
console.log(d`Password copied to the clipboard.\n`);
}
})();

0 comments on commit 02c7e68

Please sign in to comment.