tangled
alpha
login
or
join now
danabra.mov
/
typelex
56
fork
atom
An experimental TypeSpec syntax for Lexicon
56
fork
atom
overview
issues
1
pulls
2
pipelines
nicer error
danabra.mov
5 months ago
48c39715
3aaa4829
+21
-4
2 changed files
expand all
collapse all
unified
split
packages
cli
package.json
src
cli.ts
-1
packages/cli/package.json
···
1
1
{
2
2
"name": "@typelex/cli",
3
3
"version": "0.2.0",
4
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
16
-
describe: "Primary namespace pattern (e.g., app.bsky.*)",
16
16
+
describe: "Primary namespace pattern (e.g., com.example.*)",
17
17
type: "string",
18
18
demandOption: true,
19
19
})
20
20
.option("out", {
21
21
-
describe: "Output directory for generated Lexicon files (relative to cwd)",
21
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
27
+
if (!argv.namespace) {
28
28
+
console.error("Error: namespace is required");
29
29
+
console.error("Usage: typelex compile <namespace>");
30
30
+
console.error("Example: typelex compile com.example.*");
31
31
+
process.exit(1);
32
32
+
}
33
33
+
34
34
+
if (!argv.namespace.endsWith(".*")) {
35
35
+
console.error("Error: namespace must end with .*");
36
36
+
console.error(`Got: ${argv.namespace}`);
37
37
+
console.error("Example: typelex compile com.example.*");
38
38
+
process.exit(1);
39
39
+
}
40
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
42
-
.demandCommand(1, "You must specify a command")
56
56
+
.demandCommand(1)
43
57
.help()
44
58
.version()
45
59
.fail((msg, err) => {
46
60
if (err) {
47
61
console.error(err);
62
62
+
} else if (msg.includes("Not enough non-option arguments")) {
63
63
+
console.error("Error: namespace is required");
64
64
+
console.error("Usage: typelex compile <namespace>");
65
65
+
console.error("Example: typelex compile com.example.*");
48
66
} else {
49
67
console.error(msg);
50
68
}