mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
added basic cli telemetry
This commit is contained in:
@@ -4,21 +4,36 @@ import { Command } from "commander";
|
||||
import color from "picocolors";
|
||||
import * as commands from "./commands";
|
||||
import { getVersion } from "./utils/sys";
|
||||
import { capture, flush, init } from "cli/utils/telemetry";
|
||||
const program = new Command();
|
||||
|
||||
export async function main() {
|
||||
await init();
|
||||
capture("start");
|
||||
|
||||
const version = await getVersion();
|
||||
program
|
||||
.name("bknd")
|
||||
.description(color.yellowBright("⚡") + " bknd cli " + color.bold(color.cyan(`v${version}`)))
|
||||
.version(version);
|
||||
.version(version)
|
||||
.hook("preAction", (thisCommand, actionCommand) => {
|
||||
capture(`cmd_${actionCommand.name()}`);
|
||||
})
|
||||
.hook("postAction", async () => {
|
||||
await flush();
|
||||
});
|
||||
|
||||
// register commands
|
||||
for (const command of Object.values(commands)) {
|
||||
command(program);
|
||||
}
|
||||
|
||||
program.parse();
|
||||
await program.parseAsync();
|
||||
}
|
||||
|
||||
main().then(null).catch(console.error);
|
||||
main()
|
||||
.then(null)
|
||||
.catch(async (e) => {
|
||||
await flush();
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user