diff --git a/packages/cli/package.json b/packages/cli/package.json index 64897e6..b7d6b0f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,6 @@ { "name": "@typelex/cli", "version": "0.2.0", - "description": "CLI for typelex - TypeSpec-based IDL for ATProto Lexicons", "main": "dist/index.js", "type": "module", "bin": { diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 807c682..f2cbdeb 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -13,17 +13,31 @@ async function main() { (yargs) => { return yargs .positional("namespace", { - describe: "Primary namespace pattern (e.g., app.bsky.*)", + describe: "Primary namespace pattern (e.g., com.example.*)", type: "string", demandOption: true, }) .option("out", { - describe: "Output directory for generated Lexicon files (relative to cwd)", + describe: "Output directory for generated Lexicon files (must end with 'lexicons')", type: "string", default: "./lexicons", }); }, async (argv) => { + if (!argv.namespace) { + console.error("Error: namespace is required"); + console.error("Usage: typelex compile "); + console.error("Example: typelex compile com.example.*"); + process.exit(1); + } + + if (!argv.namespace.endsWith(".*")) { + console.error("Error: namespace must end with .*"); + console.error(`Got: ${argv.namespace}`); + console.error("Example: typelex compile com.example.*"); + process.exit(1); + } + const options: Record = {}; if (argv.watch) { options.watch = true; @@ -39,12 +53,16 @@ async function main() { type: "boolean", default: false, }) - .demandCommand(1, "You must specify a command") + .demandCommand(1) .help() .version() .fail((msg, err) => { if (err) { console.error(err); + } else if (msg.includes("Not enough non-option arguments")) { + console.error("Error: namespace is required"); + console.error("Usage: typelex compile "); + console.error("Example: typelex compile com.example.*"); } else { console.error(msg); }