package.json 🔗
@@ -4,7 +4,7 @@
"private": true,
"type": "module",
"bin": {
- "rumilo": "./dist/cli/index.js"
+ "rumilo": "./dist/index.js"
},
"scripts": {
"dev": "bun src/cli/index.ts",
Amolith created
Add -v/--version flag support to CLI. Also fix dist/ entry point in
package.json.
package.json | 2 +-
src/cli/index.ts | 22 +++++++++++++++++++++-
src/cli/parse-args.ts | 2 ++
3 files changed, 24 insertions(+), 2 deletions(-)
@@ -4,7 +4,7 @@
"private": true,
"type": "module",
"bin": {
- "rumilo": "./dist/cli/index.js"
+ "rumilo": "./dist/index.js"
},
"scripts": {
"dev": "bun src/cli/index.ts",
@@ -3,11 +3,31 @@ import { runWebCommand } from "./commands/web.js";
import { runRepoCommand } from "./commands/repo.js";
import { RumiloError } from "../util/errors.js";
import { parseArgs } from "./parse-args.js";
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+const VERSION = "0.1.0";
async function main() {
const { command, options, positional } = parseArgs(process.argv);
- if (!command || command === "help") {
+ // Handle version flag coming before any command (e.g., rumilo -v)
+ // When short flags come right after process.argv, they end up in 'command'
+ if (command && (command === "-v" || command === "--version") && Object.keys(options).length === 0 && positional.length === 0) {
+ console.log(`rumilo v${VERSION}`);
+ process.exit(0);
+ }
+
+ const actualCommand = command?.startsWith("-") ? undefined : command;
+
+ // Handle version/short version as flag (before command) or as command
+ if (options.version || actualCommand === "version" || actualCommand === "v") {
+ console.log(`rumilo v${VERSION}`);
+ process.exit(0);
+ }
+
+ if (!actualCommand || actualCommand === "help" || actualCommand === "--help" || actualCommand === "-h" || options.help) {
console.log("rumilo web <query> [-u URL] [--model <provider:model>] [--verbose] [--no-cleanup]");
console.log("rumilo repo -u <uri> <query> [--ref <ref>] [--full] [--model <provider:model>] [--verbose] [--no-cleanup]");
process.exit(0);
@@ -42,6 +42,8 @@ export function parseArgs(args: string[]): ParsedArgs {
// else: -u with no value — uri stays unset, command handler validates
} else if (short === "f") {
options["full"] = true;
+ } else if (short === "v") {
+ options["version"] = true;
} else {
options[short] = true;
}