-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0916a3f
commit 015142f
Showing
4 changed files
with
50 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"description": "Retrieve saved WiFi passwords across Linux, Windows, and macOS systems.", | ||
"type": "module", | ||
"private": false, | ||
"main": "./dist/bin.js", | ||
"bin": { | ||
"wifikeys": "./dist/bin.js" | ||
}, | ||
|
@@ -12,7 +13,7 @@ | |
], | ||
"author": "FADHILI Josue <[email protected]>", | ||
"scripts": { | ||
"build": "echo #!/usr/bin/env node >> dist/bin.js && esbuild --bundle src/bin.ts --platform=node --outfile=dist/bin.js --packages=external --format=esm", | ||
"build": "esbuild --bundle src/bin.ts --platform=node --outfile=dist/bin.js --packages=external --format=esm", | ||
"dev": "run-p dev:*", | ||
"dev:tsc": "tsc --watch --preserveWatchOutput", | ||
"dev:node": "node --watch dist/bin.js", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,5 @@ | ||
// #!/usr/bin/env node | ||
#!/usr/bin/env node | ||
|
||
import {Command} from 'commander'; | ||
import consola from 'consola'; | ||
import pkg from '../package.json'; | ||
import getWifiPassword from './utils/wifi-password'; | ||
|
||
const program = new Command(); | ||
|
||
program | ||
.name('wifikeys') | ||
.description('get wifi keys(passwords) CLI') | ||
.usage('command [arguments]') | ||
.version( | ||
`\u001B[1mv${pkg.version}\u001B[0m`, | ||
'-v, --version', | ||
"Output wifikeys's current version.", | ||
) | ||
.helpOption('-h, --help', 'Output usage of wifikeys.'); | ||
|
||
program | ||
.command('get [ssid]') | ||
.description('get password for wifi') | ||
.option('-n, --networks <networks...>', 'wifi networks to get passwords for') | ||
.action(async (ssid: string, options) => { | ||
try { | ||
if (options?.networks?.length) { | ||
const promises = (options.networks as string[]).map(async (ssid) => { | ||
const password: string = await getWifiPassword(ssid); | ||
console.log(`> ${ssid}: ${password} \n`); | ||
}); | ||
|
||
// Wait for all promises to resolve | ||
await Promise.all(promises); | ||
process.exit(0); | ||
} | ||
|
||
await getWifiPassword(ssid).then(console.log); | ||
process.exit(0); | ||
} catch { | ||
consola.error( | ||
'failed to get password!! check if the you have saved password for wifi network', | ||
); | ||
process.exit(0); | ||
} | ||
}); | ||
import { program } from "./command"; | ||
|
||
program.parse(process.argv); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {Command} from 'commander'; | ||
import consola from 'consola'; | ||
import pkg from '../package.json'; | ||
import getWifiPassword from './utils/wifi-password'; | ||
|
||
export const program = new Command(); | ||
|
||
program | ||
.name('wifikeys') | ||
.description('get wifi keys(passwords) CLI') | ||
.usage('command [arguments]') | ||
.version( | ||
`\u001B[1mv${pkg.version}\u001B[0m`, | ||
'-v, --version', | ||
"Output wifikeys's current version.", | ||
) | ||
.helpOption('-h, --help', 'Output usage of wifikeys.'); | ||
|
||
program | ||
.command('get [ssid]') | ||
.description('get password for wifi') | ||
.option('-n, --networks <networks...>', 'wifi networks to get passwords for') | ||
.action(async (ssid: string, options) => { | ||
try { | ||
if (options?.networks?.length) { | ||
const promises = (options.networks as string[]).map(async (ssid) => { | ||
const password: string = await getWifiPassword(ssid); | ||
console.log(`> ${ssid}: ${password} \n`); | ||
}); | ||
|
||
// Wait for all promises to resolve | ||
await Promise.all(promises); | ||
process.exit(0); | ||
} | ||
|
||
await getWifiPassword(ssid).then(console.log); | ||
process.exit(0); | ||
} catch { | ||
consola.error( | ||
'failed to get password!! check if the you have saved password for wifi network', | ||
); | ||
process.exit(0); | ||
} | ||
}); |
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