diff options
Diffstat (limited to '')
| -rw-r--r-- | src/index.ts | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/index.ts b/src/index.ts index 65349fc..01420c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,27 @@ +import { program } from 'commander' import { createContext } from './context' -import { evalList } from './eval' +import { cleanup, evalList } from './eval' -const main = async () => { - const ctx = createContext() - const resultType = ctx.entryPoint.getType() - const effects = resultType.isTuple() - ? resultType.getTupleElements() - : [resultType] - await evalList(ctx, effects) +const main = () => { + program + .name('ts-types-lang') + .description(`A runtime for typescript's type system that turns it into a general purpose, purely functional programming language!`) + + program + .command('run') + .description('Run a typescript .ts file') + .argument('<file>', 'Typescript file to run') + .action(async (filePath) => { + const ctx = createContext({ filePath }) + const resultType = ctx.entryPoint.getType() + const effects = resultType.isTuple() + ? resultType.getTupleElements() + : [resultType] + await evalList(ctx, effects) + }) + + return program.parseAsync() } main() - .then(() => process.exit(0)) - .catch((e) => (console.error(e), process.exit(1))) + .finally(() => cleanup()) |
