Skip to content

Commit 5d16ed2

Browse files
committed
review
1 parent bbb71b2 commit 5d16ed2

File tree

2 files changed

+38
-41
lines changed

2 files changed

+38
-41
lines changed

tools/x/main.ts renamed to tools/x.ts

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
#!/usr/bin/env -S deno run --allow-all
2+
13
// Copyright 2018-2026 the Deno authors. MIT license.
24

5+
/**
6+
* x - Developer CLI for contributing to Deno
7+
*
8+
* Inspired by Servo's mach tool, this script provides a unified
9+
* interface for common development tasks like building, testing, and more.
10+
*
11+
* Usage:
12+
* ./x <command> [options]
13+
*
14+
* Run `./x --help` for more information.
15+
*/
16+
317
// deno-lint-ignore-file no-console
418

519
import $ from "jsr:@david/dax@^0.42.0";
@@ -370,33 +384,31 @@ function printCommandHelp(name: string, cmd: Command) {
370384
// Entry point
371385
// ---------------------------------------------------------------------------
372386

373-
export async function main(dirname: string) {
374-
const root = $.path(dirname);
375-
const COMMANDS = buildCommands(root);
376-
const args = Deno.args;
377-
378-
if (
379-
args.length === 0 || args[0] === "--help" || args[0] === "-h" ||
380-
args[0] === "help"
381-
) {
382-
printHelp(COMMANDS);
383-
Deno.exit(0);
384-
}
387+
const root = $.path(import.meta.dirname).parent();
388+
const COMMANDS = buildCommands(root);
389+
const args = Deno.args;
385390

386-
const subcommand = args[0];
387-
const cmd = COMMANDS[subcommand];
391+
if (
392+
args.length === 0 || args[0] === "--help" || args[0] === "-h" ||
393+
args[0] === "help"
394+
) {
395+
printHelp(COMMANDS);
396+
Deno.exit(0);
397+
}
388398

389-
if (!cmd) {
390-
$.logError(`Unknown command '${subcommand}'.`);
391-
console.log();
392-
printHelp(COMMANDS);
393-
Deno.exit(1);
394-
}
399+
const subcommand = args[0];
400+
const cmd = COMMANDS[subcommand];
395401

396-
if (args.includes("--help") || args.includes("-h")) {
397-
printCommandHelp(subcommand, cmd);
398-
Deno.exit(0);
399-
}
402+
if (!cmd) {
403+
$.logError(`Unknown command '${subcommand}'.`);
404+
console.log();
405+
printHelp(COMMANDS);
406+
Deno.exit(1);
407+
}
400408

401-
await cmd.fn(args.slice(1));
409+
if (args.includes("--help") || args.includes("-h")) {
410+
printCommandHelp(subcommand, cmd);
411+
Deno.exit(0);
402412
}
413+
414+
await cmd.fn(args.slice(1));

x

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
11
#!/usr/bin/env -S deno run --allow-all --ext=ts
2-
// Copyright 2018-2026 the Deno authors. MIT license.
32

4-
/**
5-
* x - Developer CLI for contributing to Deno
6-
*
7-
* Inspired by Servo's mach tool, this script provides a unified
8-
* interface for common development tasks like building, testing, and more.
9-
*
10-
* Usage:
11-
* ./x <command> [options]
12-
*
13-
* Run `./x --help` for more information.
14-
*/
15-
16-
import { main } from "./tools/x/main.ts";
17-
18-
await main(import.meta.dirname!);
3+
import "./tools/x.ts";

0 commit comments

Comments
 (0)