An experimental TypeSpec syntax for Lexicon

nicer error

+21 -4
-1
packages/cli/package.json
··· 1 1 { 2 2 "name": "@typelex/cli", 3 3 "version": "0.2.0", 4 - "description": "CLI for typelex - TypeSpec-based IDL for ATProto Lexicons", 5 4 "main": "dist/index.js", 6 5 "type": "module", 7 6 "bin": {
+21 -3
packages/cli/src/cli.ts
··· 13 13 (yargs) => { 14 14 return yargs 15 15 .positional("namespace", { 16 - describe: "Primary namespace pattern (e.g., app.bsky.*)", 16 + describe: "Primary namespace pattern (e.g., com.example.*)", 17 17 type: "string", 18 18 demandOption: true, 19 19 }) 20 20 .option("out", { 21 - describe: "Output directory for generated Lexicon files (relative to cwd)", 21 + describe: "Output directory for generated Lexicon files (must end with 'lexicons')", 22 22 type: "string", 23 23 default: "./lexicons", 24 24 }); 25 25 }, 26 26 async (argv) => { 27 + if (!argv.namespace) { 28 + console.error("Error: namespace is required"); 29 + console.error("Usage: typelex compile <namespace>"); 30 + console.error("Example: typelex compile com.example.*"); 31 + process.exit(1); 32 + } 33 + 34 + if (!argv.namespace.endsWith(".*")) { 35 + console.error("Error: namespace must end with .*"); 36 + console.error(`Got: ${argv.namespace}`); 37 + console.error("Example: typelex compile com.example.*"); 38 + process.exit(1); 39 + } 40 + 27 41 const options: Record<string, unknown> = {}; 28 42 if (argv.watch) { 29 43 options.watch = true; ··· 39 53 type: "boolean", 40 54 default: false, 41 55 }) 42 - .demandCommand(1, "You must specify a command") 56 + .demandCommand(1) 43 57 .help() 44 58 .version() 45 59 .fail((msg, err) => { 46 60 if (err) { 47 61 console.error(err); 62 + } else if (msg.includes("Not enough non-option arguments")) { 63 + console.error("Error: namespace is required"); 64 + console.error("Usage: typelex compile <namespace>"); 65 + console.error("Example: typelex compile com.example.*"); 48 66 } else { 49 67 console.error(msg); 50 68 }