diff --git a/package.json b/package.json index 0d3f62f..29d27b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fid", - "version": "0.0.0", + "version": "0.0.1", "description": "a network observatory for tangled — enumerate every knot, check their health, watch the federation", "type": "module", "bin": { diff --git a/src/cli.ts b/src/cli.ts index 55df2fd..61be0e5 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,10 +1,11 @@ #!/usr/bin/env node +import { readFileSync } from "node:fs"; import { parse } from "@bomb.sh/args"; import { animateBanner } from "./banner.js"; const args = parse(process.argv.slice(2), { - boolean: ["json", "all", "fresh", "help"], - alias: { h: "help" }, + boolean: ["json", "all", "fresh", "help", "version"], + alias: { h: "help", v: "version" }, }); const usage = `usage: @@ -12,8 +13,17 @@ const usage = `usage: --json machine-readable output --all include localhost/dev junk knots --fresh skip the 5-minute cache + fid --version print the version `; +if (args.version) { + const pkg = JSON.parse( + readFileSync(new URL("../package.json", import.meta.url), "utf8"), + ); + console.log(`fid ${pkg.version}`); + process.exit(0); +} + const [command] = args._; if (!args.json) await animateBanner(); // keep --json pipe-clean