function Main
Main<M extends Fn>(
meta: Meta,
main: M,
): M

If the current module is the program entrypoint, runs the given main function as a separate task.

If the task throws, the error is logged and the process exits. The exit code can be specified by the exitCode field of the thrown exception. If not specified, it defaults to 1.

Example:

import { Main } from '@hackbg/fadroma'; export default Main(import.meta.main || import.meta.url, main) async function main (...args: string[]) { console.log('Program arguments:', ...args) }

Type Parameters

M extends Fn

Parameters

meta: Meta
main: M

Return Type

Main<
M extends Fn,
N,
>
(
meta: Meta,
main: Main,
alt: N,
): N

Type Parameters

M extends Fn

Parameters

meta: Meta
main: Main
alt: N

Return Type

type alias Main

A program's entrypoint.

Definition