-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.ts
More file actions
38 lines (33 loc) · 1.01 KB
/
main.ts
File metadata and controls
38 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
/**
* @eserstack/codebase — standalone CLI entry point.
*
* Usage:
* deno run --allow-all jsr:@eserstack/codebase versions
* deno run --allow-all ./main.ts release
*
* @module
*/
import * as results from "@eserstack/primitives/results";
import { runtime } from "@eserstack/standards/cross-runtime";
import { moduleDef } from "./module.ts";
import config from "./package.json" with { type: "json" };
const app = moduleDef.toCommand("codebase", config.version);
export const main = async (): Promise<
results.Result<void, { message?: string; exitCode: number }>
> => {
return await app.parse();
};
if (import.meta.main) {
const result = await main();
results.match(result, {
ok: () => {},
fail: (error) => {
if (error.message !== undefined) {
// deno-lint-ignore no-console
console.error(error.message);
}
runtime.process.setExitCode(error.exitCode);
},
});
}