From 5dbd16878546886cae5b56b67de6185bfbae0d07 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Thu, 1 Aug 2024 09:15:33 -0700 Subject: add arg parser --- src/index.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts index 95fd41f..2b3e95e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,16 @@ -import * as IO from "fp-ts/IO"; -import { readFileSync } from "fs"; - -const main: IO.IO = ConsoleLogger.log("Hello, world!"); +import * as TE from "fp-ts/lib/TaskEither"; +import { pipe } from "fp-ts/lib/function"; +import { toError } from "fp-ts/lib/Either"; +import { readConfig } from "./config"; +import { parseArgs } from "./args"; +const main: TE.TaskEither = pipe( + TE.fromEither(parseArgs(Bun.argv)), + TE.bindTo("args"), + TE.bind("config", ({ args }) => TE.fromIO(readConfig(args.testsFile))), + TE.fold( + (e) => TE.left(toError(e)), + () => TE.right(undefined), + ), +); main(); -- cgit v1.3